-
-
Save CodeBrauer/5e9625818015785e35900249eabe7971 to your computer and use it in GitHub Desktop.
jQuery AJAX Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
url: 'api/url', | |
method: 'POST', | |
data: {var:'val'}, | |
contentType: "application/json; charset=utf-8", | |
dataType: 'json' | |
}).done(function(data, textStatus, jqXHR) { | |
console.log('done'); | |
}).fail(function(jqXHR, textStatus, errorThrown) { | |
if (jqXHR.responseJSON) { | |
console.log('failed with json data'); | |
} else { | |
console.log('failed with unknown data'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment