Skip to content
tobiasz.cudnik edited this page Oct 19, 2008 · 8 revisions

Table of Contents

Example

Table of Contents

 * [#Server_Side_Ajax Server Side Ajax]
 * [#Cross_Domain_Ajax Cross Domain Ajax]
 * [#Ajax_Requests Ajax Requests]
 * [#Ajax_Events Ajax Events]
 * [#Misc Misc]

Server Side Ajax

Ajax, standing for _Asynchronous JavaScript and XML_ is combination of HTTP Client and XML parser which doesn't lock program's thread (doing request in asynchronous way).

  • phpQuery* also offers such functionality, making use of solid quality Zend_Http_Client. Unfortunately requests aren't asynchronous, but nothing is impossible. For today, instead of XMLHttpRequest you always get Zend_Http_Client instance. API unification is planned.

Cross Domain Ajax

For security reasons, by default *phpQuery* doesn't allow connections to hosts other than actual `$_SERVER['HTTP_HOST']`. Developer needs to grant rights to other hosts before making an Ajax request.

There are 2 methods for allowing other hosts

 * phpQuery::*ajaxAllowURL*($url)
 * phpQuery::*ajaxAllowHost*($host)

Ajax Requests

 * *[http://docs.jquery.com/Ajax/jQuery.ajax phpQuery::ajax]*[http://docs.jquery.com/Ajax/jQuery.ajax ($options)] Load a remote page using an HTTP request.
 * *[http://docs.jquery.com/Ajax/load load]*[http://docs.jquery.com/Ajax/load ($url, $data, $callback)] Load HTML from a remote file and inject it into the DOM.
 * *[http://docs.jquery.com/Ajax/jQuery.get phpQuery::get]*[http://docs.jquery.com/Ajax/jQuery.get ($url, $data, $callback)] Load a remote page using an HTTP GET request.
 * *[http://docs.jquery.com/Ajax/jQuery.getJSON phpQuery::getJSON]*[http://docs.jquery.com/Ajax/jQuery.getJSON ($url, $data, $callback)] Load JSON data using an HTTP GET request.
 * *[http://docs.jquery.com/Ajax/jQuery.getScript phpQuery::getScript]*[http://docs.jquery.com/Ajax/jQuery.getScript ($url, $callback)] Loads, and executes, a local JavaScript file using an HTTP GET request.
 * *[http://docs.jquery.com/Ajax/jQuery.post phpQuery::post]*[http://docs.jquery.com/Ajax/jQuery.post ($url, $data, $callback, $type)] Load a remote page using an HTTP POST request.

Ajax Events

 * *[http://docs.jquery.com/Ajax/ajaxComplete ajaxComplete]*[http://docs.jquery.com/Ajax/ajaxComplete ($callback)] Attach a function to be executed whenever an AJAX request completes. This is an Ajax Event.
 * *[http://docs.jquery.com/Ajax/ajaxError ajaxError]*[http://docs.jquery.com/Ajax/ajaxError ($callback)] Attach a function to be executed whenever an AJAX request fails. This is an Ajax Event.
 * *[http://docs.jquery.com/Ajax/ajaxSend ajaxSend]*[http://docs.jquery.com/Ajax/ajaxSend ($callback)] Attach a function to be executed before an AJAX request is sent. This is an Ajax Event.
 * *[http://docs.jquery.com/Ajax/ajaxStart ajaxStart]*[http://docs.jquery.com/Ajax/ajaxStart ($callback)] Attach a function to be executed whenever an AJAX request begins and there is none already active. This is an Ajax Event.
 * *[http://docs.jquery.com/Ajax/ajaxStop ajaxStop]*[http://docs.jquery.com/Ajax/ajaxStop ($callback)] Attach a function to be executed whenever all AJAX requests have ended. This is an Ajax Event.
 * *[http://docs.jquery.com/Ajax/ajaxSuccess ajaxSuccess]*[http://docs.jquery.com/Ajax/ajaxSuccess ($callback)] Attach a function to be executed whenever an AJAX request completes successfully. This is an Ajax Event.

Misc

 * *[http://docs.jquery.com/Ajax/jQuery.ajaxSetup phpQuery::ajaxSetup]*[http://docs.jquery.com/Ajax/jQuery.ajaxSetup ($options)] Setup global settings for AJAX requests.
 * *[http://docs.jquery.com/Ajax/serialize serialize]*[http://docs.jquery.com/Ajax/serialize ()] Serializes a set of input elements into a string of data. This will serialize all given elements.
 * *[http://docs.jquery.com/Ajax/serializeArray serializeArray]*[http://docs.jquery.com/Ajax/serializeArray ()] Serializes all forms and form elements (like the .serialize() method) but returns a JSON data structure for you to work with.

Options

Detailed options description in available at jQuery Documentation Site.

 * *`async`* `Boolean`
 * *`beforeSend`* `Function`
 * *`cache`* `Boolean`
 * *`complete`* `Function`
 * *`contentType`* `String`
 * *`data`* `Object, String`
 * *`dataType`* `String`
 * *`error`* `Function`
 * *`global`* `Boolean`
 * *`ifModified`* `Boolean`
 * *`jsonp`* `String`
 * *`password`* `String`
 * *`processData`* `Boolean`
 * *`success`* `Function`
 * *`timeout`* `Number`
 * *`type`* `String`
 * *`url`* `String`
 * *`username`* `String`

Read more at Ajax section on jQuery Documentation Site.

Clone this wiki locally