jQuery的ajax

ajax({
  url: myUrl,
  type: 'get',
  dataType: 'json',
  timeout: 1000,
  success: function (data, status) {
    console.log(data)
  },
  fail: function (err, status) {
    console.log(err)
  }
})
/默认请求参数
  {
    url: null,  // 请求连接
    type: 'GET',  // 请求类型
    data: null,  // post时请求体
    dataType: 'text',  // 返回请求的类型,有text/json两种
    jsonp: 'callback',  // jsonp请求的标志,一般不改动
    jsonpCallback: 'jsonpCallback',  //jsonp请求的函数名
    async: true,   // 是否异步
    cache: true,   // 是否缓存
    timeout:null,  // 设置请求超时
    contentType: 'application/x-www-form-urlencoded',
    success: null,  // 请求成功回调函数
    fail: null   // 请求失败回调
  }
posted @ 2018-05-07 10:53  这是一个很好的名字  阅读(143)  评论(0编辑  收藏  举报