public function success($response)
{
$pq = phpQuery::newDocument($response);
foreach ($this->calls as $k => $r) {
// check if method exists
if (!method_exists(get_class($pq), $r['method'])) {
throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
// execute method
} else {
$pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
}
}
if (!isset($this->options['dataType'])) {
$this->options['dataType'] = '';
}
switch (strtolower($this->options['dataType'])) {
case 'json':
if ($pq instanceof PHPQUERYOBJECT) {
$results = array();
foreach ($pq as $node) {
$results[] = pq($node)->htmlOuter();
}
print phpQuery::toJSON($results);
} else {
print phpQuery::toJSON($pq);
}
break;
default:
print $pq;
}
// output results
}