一个小型的ajax库,提供开箱即用的ajax方法。
Install
npm install ajax-j
Usage
;
Other Tool Method
// using es6 module ajaxJajaxJ//send post request, Content-Type is "application/json; charset=utf-8"ajaxJ // or you can using promiseajax // if import script direct, invoke method is:
param table:
param | default | desc | type |
---|---|---|---|
url | "" | 请求的链接 | string |
method | get | 请求的方法 | get,post,json |
data | null | 请求的数据 | object,string,FormData,array |
contentType | "" | 请求头 | string |
dataType | "" | 请求的类型 | jsonp |
async | true | 是否异步 | blooean |
timeOut | undefined | 超时时间 | number |
before | function(data){} | 发送之前执行的函数 | function |
success | function(response){} | 请求成功的回调函数 | function |
error | function(xhr){} | 请求报错执行的函数 | function |
complete | function(xhr){} | 请求结束的回调函数 | function |
min版本使用 javascript-minifier进行压缩