示例#1
0
//		print "</pre>\n";
//	}
//	print "\n";
//}
$testName = 'Load';
$test = PhpQuery::newDocumentFile('test.html')->find('div:first')->load('http://wikipedia.org/ div[lang]');
if (pq('div[lang]')->size()) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print "<pre>";
    print "</pre>\n";
}
print "\n";
// http://code.google.com/p/phpquery/issues/detail?id=130
$pq = PhpQuery::ajax(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . preg_replace('@/[^/]+$@', '/test_ajax_data_1', $_SERVER['REQUEST_URI']), 'success' => 'a789fhasdui3124', 'error' => 'jhdbg786213u8dsfg7y'));
function a789fhasdui3124($html)
{
    $testName = 'AJAX request text node';
    if ($html == 'hello world') {
        print "Test '{$testName}' PASSED :)";
    } else {
        print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    }
    print "\n";
}
function jhdbg786213u8dsfg7y()
{
    $testName = 'AJAX request text node';
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
示例#2
0
 public static function getJSON($url, $data = null, $callback = null)
 {
     if (!is_array($data)) {
         $callback = $data;
         $data = null;
     }
     // TODO some array_values on this shit
     return PhpQuery::ajax(array('type' => 'GET', 'url' => $url, 'data' => $data, 'success' => $callback, 'dataType' => 'json'));
 }