then() - are invoked, in the order they are registered. It receives the returned data, a string containing the success code, and the jqXHR object. success callback option is invoked, if the request succeeds.It receives the returned data and the value of dataType, and must return the (possibly altered) data to pass on to success. dataFilter callback option is invoked immediately upon successful receipt of response data.Some built-in errors will provide a string as the exception object: "abort", "timeout", "No Transport". It receives the jqXHR, a string indicating the error type, and an exception object if applicable. error callback option is invoked, if the request fails.beforeSend callback option is invoked it receives the jqXHR object and the settings object as parameters.The callback hooks provided by $.ajax() are as follows: See Deferred object methods, which are implemented internally for these $.ajax() callback hooks. The beforeSend, error, dataFilter, success and complete options all accept callback functions that are invoked at the appropriate times.Īs of jQuery 1.5, the fail and done, and, as of jQuery 1.6, always callback hooks are first-in, first-out managed queues, allowing for more than one callback for each hook. No onreadystatechange mechanism is provided, however, since done, fail, always, and statusCode cover all conceivable requirements. setRequestHeader( name, value ) which departs from the standard by replacing the old value with the new one rather than concatenating the new value to the old one.statusText (may be an empty string in HTTP/2).responseXML and/or responseText when the underlying request responded with xml and/or text, respectively.The this reference within all callbacks is the object in the context option passed to $.ajax in the settings if context is not specified, this is a reference to the Ajax settings themselves.įor backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods: Refer to deferred.then() for implementation details. fail() methods, allowing (as of jQuery 1.8) the underlying Promise to be manipulated. When data is an object, jQuery generates the data string from the object's key/value pairs unless the processData option is set to false. If the HTTP method is one that cannot have an entity body, such as GET, the data is appended to the URL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |