mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
支持表单模拟ajax和pjax请求 增加var_ajax var_pjax 配置参数
This commit is contained in:
@@ -95,6 +95,10 @@ return [
|
|||||||
'url_controller_layer' => 'controller',
|
'url_controller_layer' => 'controller',
|
||||||
// 表单请求类型伪装变量
|
// 表单请求类型伪装变量
|
||||||
'var_method' => '_method',
|
'var_method' => '_method',
|
||||||
|
// 表单ajax伪装变量
|
||||||
|
'var_ajax' => '_ajax',
|
||||||
|
// 表单pjax伪装变量
|
||||||
|
'var_pjax' => '_pjax',
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 模板设置
|
// | 模板设置
|
||||||
|
|||||||
@@ -1186,22 +1186,34 @@ class Request
|
|||||||
/**
|
/**
|
||||||
* 当前是否Ajax请求
|
* 当前是否Ajax请求
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param bool $ajax true 获取原始ajax请求
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isAjax()
|
public function isAjax($ajax = false)
|
||||||
{
|
{
|
||||||
$value = $this->server('HTTP_X_REQUESTED_WITH');
|
$value = $this->server('HTTP_X_REQUESTED_WITH', '', 'strtolower');
|
||||||
return (!is_null($value) && strtolower($value) == 'xmlhttprequest') ? true : false;
|
$result = ('xmlhttprequest' == $value) ? true : false;
|
||||||
|
if (true === $ajax) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
return $this->param(Config::get('var_ajax')) ? true : $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前是否Pjax请求
|
* 当前是否Pjax请求
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param bool $pjax true 获取原始pjax请求
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isPjax()
|
public function isPjax($pjax = false)
|
||||||
{
|
{
|
||||||
return !is_null($this->server('HTTP_X_PJAX')) ? true : false;
|
$result = !is_null($this->server('HTTP_X_PJAX')) ? true : false;
|
||||||
|
if (true === $pjax) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
return $this->param(Config::get('var_pjax')) ? true : $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user