ajax({
method:'GET',
url:'https://passer-by.com/',
data:{
keyword:'test'
}
}).then(function(json){
console.log(json);
});
参数 | 默认值 | 说明 |
---|---|---|
baseURL | location.origin | 基础域 |
method | 'GET' | 请求方法 |
url | - | 请求地址 |
data | {} | 请求参数 |
headers | {} | 请求头设置 |
withCredentials | false | 是否携带凭证 |
crossDomain | false | 是否跨域 |
cache | false | 是否设置缓存 |
timeout | 5000 | 超时时间 |
jsonp | callback | jsonp回调函数引用 |
jsonpCallback | jsonp_20240823 | jsonp回调函数名称 |
responseType | 'json' | 响应数据格式 |
dataFormatter | null | 数据格式化处理 |
onTimeout | function(){} | 超时时触发函数 |