Skip to content

Instantly share code, notes, and snippets.

@driverdan
Created September 18, 2010 16:50
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 driverdan/585848 to your computer and use it in GitHub Desktop.
Save driverdan/585848 to your computer and use it in GitHub Desktop.
Sets global var someGlobal to XHR response
var XMLHttpRequest = require("../XMLHttpRequest").XMLHttpRequest
,xhr
,someGlobal = "foo";
console.log("someGlobal: " + someGlobal);
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
someGlobal = this.responseText;
console.log("Request completed. someGlobal: " + someGlobal);
}
};
xhr.open("GET", "http://www.google.com/");
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment