1.0.5 • Published 4 years ago
ajax-li v1.0.5
ajax
Including
<script src="./dist/ajax.js"></script>
Usage
ajax({
method:'post',
url:'http://192.168.6.48/ajax/server2.php',
data:{name:'list'}, //请求参数
timeout:10000, //设置请求超时 ms
// requestHeader: { // 设置请求头
// key:'Content-type',
// value:'application/x-www-form-urlencoded'
// }
}).then(res=>{
console.log( res )
}).catch(err=>{
console.log( err )
})
API
ajax(data)
- data.method 请求方式,目前支持 get/post/head
- data.url url
- data.data post请求时请求参数。
{username:"xiaoming"}
- data.timeout 超时,单位毫秒。可选参数
- data.header
{ key:'Content-type', value:'application/x-www-form-urlencoded' }