Skip to content

Instantly share code, notes, and snippets.

@vaibhavmule
Created December 11, 2015 16:24
Show Gist options
  • Save vaibhavmule/cd447d4f17369a9347d6 to your computer and use it in GitHub Desktop.
Save vaibhavmule/cd447d4f17369a9347d6 to your computer and use it in GitHub Desktop.
Make a HTTP request with XMLHttpRequest.
// GET Request
var xhr = new XMLHttpRequest();
// Three Arguments: Method, Url and true is optional boolean for async
xhr.open("GET", "http://example.com/", true);
// Log the response
xhr.onload = function () {
console.log(xhr.responseText);
};
// Send the request
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment