https://github.com/willworks/ajaxrequest
Ajax数据请求模拟,可用于接口还未开通时候的模拟返回数据
https://github.com/willworks/ajaxrequest
Last synced: 12 months ago
JSON representation
Ajax数据请求模拟,可用于接口还未开通时候的模拟返回数据
- Host: GitHub
- URL: https://github.com/willworks/ajaxrequest
- Owner: willworks
- License: mit
- Created: 2015-11-26T15:07:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-29T11:36:34.000Z (over 10 years ago)
- Last Synced: 2025-05-18T20:08:26.501Z (about 1 year ago)
- Language: JavaScript
- Size: 282 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AjaxRequest
Ajax数据请求模拟,可用于接口还未开通时候的模拟返回数据
#### 主要插件
- [jquery-mockjax](https://github.com/jakerella/jquery-mockjax) 提供基本功能实现
- [mockJSON](https://github.com/mennovanslooten/mockJSON) 内置json和jsonp请求返回的处理
- [jquery.tmpl](https://github.com/BorisMoore/jquery-tmpl) jq模板引擎
#### 使用方法
- 发起ajax请求
$.ajax({
url : "http://host/api/api_name",
brand_ids : "01234,56789",//批量查询
dataType : "jsonp",
jsonp : "jsonp",
success : function(res){
// 主要逻辑
}
});
- 在引入jquery-mockjax后,请求接口跟真正的设置一样,配置好返回数据,就可以进行请求的拦截、
$.mockjax({
url: 'http://host/api/api_name',
status: 200,
responseTime: 900,
// 模拟数据
responseText:
{
"code": 0,
"data": {
data_list: [
// 数据返回格式
]
},
"msg": "success"
}
});