Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getJson() {
  2.     return new Promise(function(resolve, reject) {
  3.         xhr.open("GET", "http://name.ru/res.json", true);
  4.         xhr.onreadystatechange = function() {
  5.         if (xhr.readyState == 4)
  6.             resolve(rxhr.responseText)
  7.         }
  8.  
  9.         xhr.send();
  10.     }
  11. }
  12.  
  13. getJson().then(function(response) {
  14.     console.log(response)
  15. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement