This is my first time when I use AJAX, which I read on it, and this is also my first time when I do it with js. I think I embarrassed myself along the way.
I try to dynamically create a new restaurant page, so every time the administrator clicks onclick, a new web page is created with the contents of the new restaurant page that I have already created.
At the moment I reached the click of a button, a new web page is being created successfully, however I have no idea how to access the new web page, I also wanted to display a link to the newly created web page, because it is created like, for example, using earlier. in js to show a dynamic function, for example, in front of my o'clock button.
HTML
<html>
<body>
<button onclick="makePage()">click</button>
<script src="makePage.js">
</script>
</body>
</html>
Js
function makePage(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200)
alert("webpage " + xmlhttp.responseText + " was successfully created!");
}
var content = "<html><head><meta charset=\"utf-8\" /> </head><body>new website<script>alert(\"test\")</script></body></html>";
xmlhttp.open("GET","makePage.php?content=" + content,true);
xmlhttp.send();
}
PHP
<?php
$content = $_GET["content"];
$file = uniqid() . ".html";
file_put_contents($file, $content);
echo $file;
?>
? , . .