Skip to content

Instantly share code, notes, and snippets.

@PhilKershaw
Created September 24, 2013 14:33
Show Gist options
  • Save PhilKershaw/6685677 to your computer and use it in GitHub Desktop.
Save PhilKershaw/6685677 to your computer and use it in GitHub Desktop.
Sample xhr request
var formData = new FormData();
var str_url = '/ajax';
formData.append('id', int_id);
var xhr = new XMLHttpRequest();
xhr.open('POST', str_url, true);
xhr.onload = function(e) {
if (this.status == 200) {
if (/success/i.test(this.responseText)) {
alert('Category Box deleted successfully.');
} else {
alert(this.responseText);
}
}
};
xhr.send(formData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment