Skip to content

Instantly share code, notes, and snippets.

@thebapi
Created February 7, 2014 18:06
Show Gist options
  • Save thebapi/8868313 to your computer and use it in GitHub Desktop.
Save thebapi/8868313 to your computer and use it in GitHub Desktop.
jquery get request
var jqxhr = $.getJSON( "example.json", function() {
console.log( "success" );
})
.done(function() {
console.log( "second success" );
})
.fail(function() {
console.log( "error" );
})
.always(function() {
console.log( "complete" );
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.complete(function() {
console.log( "second complete" );
});
---------
$.ajax({
url: "http://fiddle.jshell.net/favicon.png",
beforeSend: function( xhr ) {
xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
}
})
.done(function( data ) {
})
.fail( function (){
console.log("Fails");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment