Advertisement
TheTintin

Untitled

May 30th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. function httpGetAsync(theUrl, callback) {
  2. var xhr = new XMLHttpRequest();
  3. var argsToCallback = Array.prototype.slice.call(arguments, 2);
  4.  
  5. xhr.onreadystatechange = function() {
  6. if (xhr.readyState === 4 && xhr.status === 200) {
  7. var args = [JSON.parse(xhr.responseText)];
  8. args = args.concat(argsToCallback);
  9. callback.apply(this, args);
  10. } else {
  11. console.log("Status de la r�ponse:" + this.status, this.statusText);
  12. }
  13. }
  14. xhr.open("GET", theUrl, true);
  15. xhr.send(null);
  16. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement