Skip to content

Instantly share code, notes, and snippets.

@mikekwright
Created February 13, 2013 21:30
Show Gist options
  • Save mikekwright/4948502 to your computer and use it in GitHub Desktop.
Save mikekwright/4948502 to your computer and use it in GitHub Desktop.
Javascript XMLHttpRequest that is used to return the Todo objects for ASP.NET MVC 4 Tutorial.
function getTodos() {
var request = new XMLHttpRequest();
request.open("Get", "/api/Todo", true);
request.onload = function() {
console.log("Returned");
if (request.error) {
console.log(request.error);
} else {
var response = JSON.parse(request.responseText);
console.log(response);
}
};
request.send();
}
getTodos();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment