当前位置: 首页>>代码示例>>PHP>>正文


PHP phpQuery::ajax方法代码示例

本文整理汇总了PHP中phpQuery::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::ajax方法的具体用法?PHP phpQuery::ajax怎么用?PHP phpQuery::ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpQuery的用法示例。


在下文中一共展示了phpQuery::ajax方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($data)
 {
     $pq = null;
     include_once dirname(__FILE__) . '/../phpQuery/phpQuery.php';
     if (file_exists(dirname(__FILE__) . '/jQueryServer.config.php')) {
         include_once dirname(__FILE__) . '/jQueryServer.config.php';
         if ($jQueryServerConfig) {
             $this->config = array_merge_recursive($this->config, $jQueryServerConfig);
         }
     }
     if ($this->config['refererMustMatch']) {
         foreach ($this->config['allowedRefererHosts'] as $i => $host) {
             if ($host == '.') {
                 $this->config['allowedRefererHosts'][$i] = $_SERVER['HTTP_HOST'];
             }
         }
         $referer = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
         $authorized = $referer && in_array($referer, $this->config['allowedRefererHosts']);
         if (!$authorized) {
             throw new Exception("Host '{$_SERVER['HTTP_REFERER']}' not authorized to make requests.");
             return;
         }
     }
     //		phpQueryClass::$debug = true;
     //		if (! function_exists('json_decode')) {
     //			include_once(dirname(__FILE__).'/JSON.php');
     //			$this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     //		}
     //		$data = $this->jsonDecode($data);
     $data = phpQuery::parseJSON($data);
     // load document (required for first $data element)
     if (is_array($data[0]) && isset($data[0]['url'])) {
         $this->options = $data[0];
         $ajax = $this->options;
         $this->calls = array_slice($data, 1);
         $ajax['success'] = array($this, 'success');
         phpQuery::ajax($ajax);
     } else {
         throw new Exception("URL needed to download content");
         break;
     }
 }
开发者ID:AloneFallen,项目名称:phpquery,代码行数:42,代码来源:jQueryServer.php

示例2: load

 /**
  * Enter description here...
  *
  * @link http://docs.jquery.com/Ajax/load
  * @return phpQuery|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  * @todo Support $selector
  */
 public function load($url, $data = null, $callback = null)
 {
     if ($data && !is_array($data)) {
         $callback = $data;
         $data = null;
     }
     if (mb_strpos($url, ' ') !== false) {
         $matches = null;
         if (extension_loaded('mbstring') && phpQuery::$mbstringSupport) {
             mb_ereg('^([^ ]+) (.*)$', $url, $matches);
         } else {
             preg_match('@^([^ ]+) (.*)$@', $url, $matches);
         }
         $url = $matches[1];
         $selector = $matches[2];
         // FIXME this sucks, pass as callback param
         $this->_loadSelector = $selector;
     }
     $ajax = array('url' => $url, 'type' => $data ? 'POST' : 'GET', 'data' => $data, 'complete' => $callback, 'success' => array($this, '__loadSuccess'));
     phpQuery::ajax($ajax);
     return $this;
 }
开发者ID:limi58,项目名称:fetchJD,代码行数:29,代码来源:phpQueryObject.php

示例3: getJSON

 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'));
 }
开发者ID:RetroscopeCreative,项目名称:RouterunnerCMS,代码行数:9,代码来源:phpQuery.php

示例4: handleSubmit

 /**
  * Enter description here...
  *
  * @param unknown_type $e
  * @TODO trigger submit for form after form's  submit button has a click event
  */
 public static function handleSubmit($e, $callback = null)
 {
     $node = phpQuery::pq($e->target);
     if (!$node->is('form') || !$node->is('[action]')) {
         return;
     }
     // TODO document.location
     $xhr = isset($node->document->xhr) ? $node->document->xhr : null;
     $submit = pq($e->relatedTarget)->is(':submit') ? $e->relatedTarget : $node->find('*:submit:first')->get(0);
     $data = array();
     foreach ($node->serializeArray($submit) as $r) {
         // XXXt.c maybe $node->not(':submit')->add($sumit) would be better ?
         //		foreach($node->serializeArray($submit) as $r)
         $data[$r['name']] = $r['value'];
     }
     $options = array('type' => $node->attr('method') ? $node->attr('method') : 'GET', 'url' => resolve_url($e->data[0], $node->attr('action')), 'data' => $data, 'referer' => $node->document->location);
     if ($node->attr('enctype')) {
         $options['contentType'] = $node->attr('enctype');
     }
     $xhr = phpQuery::ajax($options, $xhr);
     if ((!$callback || !$callback instanceof Callback) && $e->data[1]) {
         $callback = $e->data[1];
     }
     if ($xhr->getLastResponse()->isSuccessful() && $callback) {
         phpQuery::callbackRun($callback, array(self::browserReceive($xhr)));
     }
 }
开发者ID:fobiaphp,项目名称:phpquery,代码行数:33,代码来源:WebBrowser.php

示例5: preg_replace

//		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> !!! ";
}
开发者ID:limi58,项目名称:fetchJD,代码行数:31,代码来源:test_ajax.php

示例6: post

 public static function post($url, $data = null, $callback = null, $type = null)
 {
     if (!is_array($data)) {
         $callback = $data;
         $data = null;
     }
     return phpQuery::ajax(array('type' => 'POST', 'url' => $url, 'data' => $data, 'success' => $callback, 'dataType' => $type));
 }
开发者ID:Alexabr23,项目名称:bomberos120,代码行数:8,代码来源:phpQuery-onefile.php


注:本文中的phpQuery::ajax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。