-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ajax.php
executable file
·64 lines (58 loc) · 1.74 KB
/
test_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
//error_reporting(E_ALL);
set_include_path(
get_include_path()
.':/home/bob/Sources/PHP/zend-framework/'
);
require_once('../phpQuery/phpQuery.php');
phpQuery::$debug = true;
phpQuery::$ajaxAllowedHosts[] = 'wikipedia.org';
phpQuery::$ajaxAllowedHosts[] = 'google.com';
phpQuery::$ajaxAllowedHosts[] = 'code.google.com';
phpQuery::$ajaxAllowedHosts[] = 'www.google.com';
//$pq = phpQuery::ajax(array(
// 'url' => 'http://wikipedia.org/',
// 'success' => 'v87shs79d8fhs9d'
//));
//function v87shs79d8fhs9d($html) {
// $title = phpQuery::newDocument($html)->find('title');
// $testName = 'Simple AJAX';
// if ( strpos(strtolower($title->html()), 'wikipedia') !== false )
// print "Test '$testName' PASSED :)";
// else {
// print "Test '$testName' <strong>FAILED</strong> !!! ";
// print "<pre>";
// print_r($title->whois());
// 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";
//$testName = 'gdata plugin';
//phpQuery::extend('gdata');
//$xhr = phpQuery::$plugins->gdata('[email protected]', 'XXX');
//$url = 'http://code.google.com/p/phpquery/w/edit/Callbacks';
//phpQuery::ajax(array('url' => $url, 'success' => 'ksjsdgh892jh23'), $xhr);
//function ksjsdgh892jh23($html) {
// print $html;
// print pq($html)->find('script')->remove()->end();
// if (pq('div[lang]')->size())
// print "Test '$testName' PASSED :)";
// else {
// print "Test '$testName' <strong>FAILED</strong> !!! ";
// print "<pre>";
// print "</pre>\n";
// }
// print "\n";
//}