Skip to content

Instantly share code, notes, and snippets.

@brettvaida
Created November 25, 2017 20:43
Show Gist options
  • Save brettvaida/c95ccd48de26b061e553ea606392a728 to your computer and use it in GitHub Desktop.
Save brettvaida/c95ccd48de26b061e553ea606392a728 to your computer and use it in GitHub Desktop.
AJAX POST request boilerplate with jQuery
$.ajax({
url: 'https://api-to-call.com/endpoint',
type: 'POST',
data: JSON.stringify({id: 200}),
dataType: 'json',
success(response) {
console.log(response);
},
error(jqXHR, status, errorThrown) {
console.log(jqXHR);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment