itpao25

XMLHttpRequest()

Aug 19th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var xhr = new XMLHttpRequest();
  2.  xhr.open("GET", "URL", true);
  3.  xhr.onreadystatechange = function() {
  4.    if (xhr.readyState == 4) {
  5.     data = JSON.parse(xhr.responseText);
  6.       alert(data);
  7.    }
  8.  }
  9.  xhr.send();
  10. ||
  11.  xhr.onreadystatechange = function() {
  12.     if(xhr.readyState == 4 && xhr.status == 200) {
  13.         alert(xhr.responseText);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment