Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h2>Get data as JSON from a PHP file on the server.</h2>
- <p id="demo"></p>
- <script>
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- myObj = JSON.parse(this.responseText);
- document.getElementById("demo").innerHTML = myObj.name;
- }
- };
- xmlhttp.open("GET", "demo_file.php", true);
- xmlhttp.send();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement