Skip to content

Instantly share code, notes, and snippets.

@ezos86
Created August 6, 2013 05:47
Show Gist options
  • Save ezos86/6162332 to your computer and use it in GitHub Desktop.
Save ezos86/6162332 to your computer and use it in GitHub Desktop.
Jquery Ajax Submit to API Example with Complete PostBack
$.ajax({
type: 'GET',
url: reportsUrl,
beforeSend : function(xhr) {
var base64 = Base64.encode(username + ":" + password);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
contentType: 'plain/text',
xhrFields: {
withCredentials: true
},
//username: username,
//password: password,
headers: {},
success: function (json) {
reports = json;
updateReportsTables();
},
error: function() {
$('#div').html("<p>Error.</p>");
},
complete : function () {
displayLoading(false);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment