Advertisement
Guest User

2016 10 29 12 50

a guest
Oct 28th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>The XMLHttpRequest Object</h1>
  6.  
  7. <button type="button" onclick="loadDoc()">Request data</button>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. function loadDoc() {
  13.   var xhttp = new XMLHttpRequest();
  14.   xhttp.onreadystatechange = function() {
  15.     if (this.readyState == 4 && this.status == 200) {
  16.      var respon = this.responseText;
  17.       var data = JSON.parse(respon);
  18.      
  19.       // ambil data2 nya melalui variabel data
  20.       // ...
  21.  
  22.     }
  23.   };
  24.   xhttp.open("POST", "file_php_tujuan.php", true);
  25.   xhttp.send("username=myusername&password=89237j4tr2834yrdj2");
  26. }
  27. </script>
  28.  
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement