XHR GET Request W/ Callback


/ Published in: JavaScript
Save to your folder(s)

Make a simple XHR Request:

get(url, function(resp)(){ window.alert(resp); });

Source is minified.


Copy this code and paste it in your HTML
  1. function get(b,a){var c=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){a(c.responseText)}};c.open("GET",b,true);c.send()};

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.