Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created September 9, 2016 07:35
Show Gist options
  • Save andreasvirkus/b298098ed492e08e1e8c505bd5845118 to your computer and use it in GitHub Desktop.
Save andreasvirkus/b298098ed492e08e1e8c505bd5845118 to your computer and use it in GitHub Desktop.
var ajaxPost;
(function() {
ajaxPost = function (endPoint, obj, failCallback) {
var xhr = new XMLHttpRequest();
xhr.open('POST', endPoint, true);
xhr.onload = function() {
if (xhr.status != 200 && xhr.status != 4) {
failCallback();
}
};
xhr.onerror = function() {
failCallback();
};
xhr.send(JSON.stringify(obj));
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment