jQuery in Action

254
CHAPTER 8
Talk to the server with Ajax
As the syntax for the commands that attach each of these function types are iden-
tical, they are presented in the following single syntax description:
Each of these global callbacks is invoked at a certain point during the processing
of an Ajax request or conditionally depending upon the response status, assum-
ing that global functions were enabled for the Ajax request. Table 8.3 describes
when each global callback type is invoked and what parameters are passed to it.
Command syntax: Ajax global functions
ajaxStart(callback)
ajaxSend(callback)
ajaxSuccess(callback)
ajaxError(callback)
ajaxComplete(callback)
ajaxStop(callback)
Attaches the passed function to all matched elements invoked when the specified point in
the processing of an Ajax request takes place.
Parameters
callback
(Function) The callback function to be attached. See table 8.3 for information
on when the callback is invoked and what parameters it will be passed.
Returns
The wrapped set.
Table 8.3 Global Ajax callbacks, listed in order of firing
Global callback type
When invoked
Parameters
ajaxStart
When a jQuery Ajax function or com-
mand is started, but before the XHR
instance is created
A Global Callback Info object with
type set to ajaxStart
ajaxSend
After the XHR instance has been cre-
ated, but before it's sent to the server
A Global Callback Info object with
type set to ajaxSend
The XHR instance
The properties used by the
$.ajax()
function
ajaxSuccess
After the request has returned from the
server and the response contains a
success status code
A Global Callback Info object with
type set to ajaxSuccess
The XHR instance
The properties used by the
$.ajax()
function
continued on next page


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.