Created
April 4, 2014 08:00
-
-
Save Kcko/9970145 to your computer and use it in GitHub Desktop.
Complete ajax
This file contains 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
var jqxhr = $.ajax({ | |
url: url, | |
type: "GET", // default is GET but you can use other verbs based on your needs. | |
cache: true, // default is true, but false for dataType 'script' and 'jsonp', so set it on need basis. | |
data: {}, // add your request parameters in the data object. | |
dataType: "json", // specify the dataType for future reference | |
jsonp: "callback", // only specify this to match the name of callback parameter your API is expecting for JSONP requests. | |
statusCode: { // if you want to handle specific error codes, use the status code mapping settings. | |
404: handler404, | |
500: handler500 | |
} | |
}); | |
jqxhr.done(successHandler); | |
jqxhr.fail(failureHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment