Skip to content

Instantly share code, notes, and snippets.

@nlf
Created February 16, 2015 22:21
Show Gist options
  • Save nlf/25c59354e1575a561f33 to your computer and use it in GitHub Desktop.
Save nlf/25c59354e1575a561f33 to your computer and use it in GitHub Desktop.
var request = new XMLHttpRequest();
request.onload = function () {
// request.status is the HTTP status code of the response
// request.responseText is whatever data the server sent back
// easiest for this would be something like
if (response.status === 200) {
// form posted ok
} else {
// form failed to post
}
};
request.open('POST', '/submit', true);
request.setRequestHeader("Content-Type", "application/json");
request.send(formData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment