# pjax
**Repository Path**: ipking/pjax
## Basic Information
- **Project Name**: pjax
- **Description**: No description available
- **Primary Language**: JavaScript
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2016-12-14
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
#pjax.js
#使用方法
引入js文件
```
```
直接绑定
```
```
通过异步加载进来的,on 绑定时,可以使用
```
```
使用条件:
需要 jQuery 1.8.x 或者更高版本.
后端需要做的
类似于ajax, 异步请求的时候后端不能将公用的内容也返回。
所以需要一个判断是否pjax请求的接口。如:php可以借鉴下面的实现
```
function is_pjax(){
return array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX'];
}
```
```
$id = $this->_get('id', 'intval');
$info = $mod->find($id);
$this->assign('info', $info);
if (is_pjax()) {
$response = $this->fetch();
$this->display('response');
} else {
$this->display();
}
```