Skip to content

Instantly share code, notes, and snippets.

@nabinno
Created July 24, 2014 22:43
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 nabinno/a526cdc2b2ac6e14aa78 to your computer and use it in GitHub Desktop.
Save nabinno/a526cdc2b2ac6e14aa78 to your computer and use it in GitHub Desktop.
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { // DONE
if (xhr.status == 200) { // OK
alert(xhr.responseText);
} else {
alert("status = " + xhr.status);
}
}
}
// GET
xhr.open("GET", "hoge.txt");
xhr.send();
//// POST
// xhr.open("POST", "hoge.cgi");
// xhr.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
// xhr.send("a=b&c=d");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment