Export to GitHub

phpquery - Ajax.wiki


Example

pq('#element')->load('http://somesite.com/page .inline-selector')->...

Table of Contents

  • Server Side Ajax
  • Cross Domain Ajax
  • Ajax Requests
  • Ajax Events
  • 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)

// connect to google.com phpQuery::ajaxAllowHost('google.com'); phpQuery::get('http://google.com/ig'); // or using same string $url = 'http://google.com/ig'; phpQuery::ajaxAllowURL($url); phpQuery::get($url);

Ajax Requests

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.