Skip to content

Instantly share code, notes, and snippets.

@sartas
Forked from sindresorhus/simplexhr.js
Created March 2, 2013 17:09
Show Gist options
  • Select an option

  • Save sartas/5072011 to your computer and use it in GitHub Desktop.

Select an option

Save sartas/5072011 to your computer and use it in GitHub Desktop.
var xhr = function() {
var xhr = new XMLHttpRequest();
return function( method, url, callback ) {
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 ) {
callback( xhr.responseText );
}
};
xhr.open( method, url );
xhr.send();
};
}();
/*
xhr('get', 'http://google.com', function(data) {
console.log(data);
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment