Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      var req = new XMLHttpRequest();
  2.     req.open('GET', '/path/to/my/thing', true); // true means it's asynchronous, you want that
  3.     req.responseType = 'json';
  4.     req.send(null); // because you don't have data to send, you're just requesting
  5.     function shit_broke() {
  6.  
  7.     }
  8.     req.onload = function() {
  9.         if (req.status==200) {
  10.             console.log(req.response);
  11.             _this.importBot(req.response);
  12.             // do something when it's chill
  13.         } else {
  14.             shit_broke();
  15.             // do something when it's not chill, and its probably your server
  16.             // because the status code is not 200
  17.         }
  18.     };
  19.     req.onerror = function() {
  20.         shit_broke();
  21.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement