Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Created August 21, 2013 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinmetcalf/6299171 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/6299171 to your computer and use it in GitHub Desktop.
asyncAjax(url){
var def = deferred();
var ajax = new XMLHttpRequest();
ajax.open("GET", url);
ajax.onreadystatechange = function() {
if (request.readyState === 4 && request.status === 200) {
def.resolve(JSON.parse(request.responseText));
}
};
request.send();
return def.promise;
}
syncAjax(url){
var ajax = new XMLHttpRequest();
ajax.open("GET", url, false);
request.send();
JSON.parse(request.responseText);
}
@ilonamor
Copy link

dh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment