Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <button type="button" id="btn" onclick="loadDoc()">Request data</button>
- <p id="demo"></p>
- <script>
- document.getElementById("btn").click();
- function loadDoc() {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("demo").innerHTML = this.responseText;
- }
- };
- xhttp.open("GET", "test.php", true);
- xhttp.send();
- setTimeout(2);
- document.getElementById("btn").click();
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment