Ajax Template




var ajaxVar = $.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: {
     404: function() {
        alert( "page not found" );
     },
500: function() {
        alert( "Server Error" );
     }
   }
});
ajaxVar.done(successHandler);
ajaxVar.fail(failureHandler);
 
 
Ref
http://lab.abhinayrathore.com/jquery-standards/

Post a Comment