本文整理汇总了PHP中ajax::loadAJAX方法的典型用法代码示例。如果您正苦于以下问题:PHP ajax::loadAJAX方法的具体用法?PHP ajax::loadAJAX怎么用?PHP ajax::loadAJAX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ajax
的用法示例。
在下文中一共展示了ajax::loadAJAX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadRoute
public static function loadRoute()
{
$r = array('action' => 'default', 'values' => array(), 'method' => 'get', 'ajax' => false, 'view' => 'default');
if (isset($_SERVER['REQUEST_METHOD'])) {
$method = strtoupper($_SERVER['REQUEST_METHOD']);
} else {
$method = 'CLI';
}
if ($method == 'GET') {
$r['values'] = $_GET;
if (isset($_GET['_view'])) {
$r['view'] = $_GET['_view'];
}
} elseif ($method == 'POST') {
$r['values'] = $_POST;
$r['method'] = 'post';
if (isset($_POST['_view'])) {
$r['view'] = $_POST['_view'];
}
} elseif ($method == 'CLI') {
global $argv;
$r['method'] = 'cli';
$r['values'] = $argv;
}
$cfg_ajax_test = array(array('field' => 'ajax', 'data_type' => 'http', 'return_type' => 'any', 'action' => 'ajax'), array('field' => 'json', 'data_type' => 'http', 'return_type' => 'json', 'action' => 'json'), array('field' => 'jsonrpc', 'data_type' => 'jsonrpc', 'return_type' => 'json', 'action' => 'method'), array('field' => 'callback', 'data_type' => 'http', 'return_type' => 'jsonp', 'action' => 'method'), array('field' => 'jsonpCallback', 'data_type' => 'http', 'return_type' => 'jsonp', 'action' => 'method'));
$ajax_type = null;
if (isset($_REQUEST)) {
foreach ($cfg_ajax_test as $test) {
if (isset($_REQUEST[$test['field']])) {
$ajax_type = $test;
break;
}
}
}
if (!is_null($ajax_type)) {
$r['ajax'] = true;
$r['method'] = strtolower($method);
$r['action'] = strtolower($_REQUEST[$ajax_type['action']]);
$r['view'] = 'default';
if ($ajax_type['data_type'] == 'http') {
$r['values'] = $r['method'] == 'get' ? $_GET : $_POST;
} elseif ($ajax_type['data_type'] == 'jsonrpc') {
$r['values'] = json_decode(file_get_contents('php://input'));
$r['action'] = $r['values']['method'];
}
if ($ajax_type['return_type'] == 'json' || $ajax_type['return_type'] == 'jsonp') {
ajax::loadAJAX($r['values']);
ajax::setType($ajax_type['return_type']);
}
//error_log(print_r($ajax_type, true));
}
if (isset($r['values']['a'])) {
$r['action'] = strtolower($r['values']['a']);
}
return $r;
}