I want to get an html page to be able to get a string of anything, for example 'text'
, without the user of the website being able to see the source of where I got it from. I have a working method right now, but the user can see the source, which is not what I want. Anyone know any ways?
I have my code below:
challenge.php:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
</head>
<body>
<h1 class="result">Result: </h1>
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
var req = new XMLHttpRequest();
req.onload = function() {
$(".result").html(this.responseText);
}
req.open("get", "get-data.php", true);
req.send();
</script>
</body>
</html>
get-data.php:
<?php
echo json_encode("text");
?>
The only problem for this code is when the user does ctrl + u, they can see "get-data.php. Then they can simply go to that that page and see the text.