文档中心 > 智能硬件

ajax

更新时间:2018/08/02 访问次数:1327

ajax(options)

发送http请求。任何http请求均需通过该API调用

Arguments

  1. options: 请求选项
参数名 是否必选 备注
url 请求URL
data 请求数据(get时,会作为query string自动加到URL之后)
dataType 请求类型: 'json', 'jsonp'。默认为'json'
method 请求的method: 'get', 'post' …, 默认为'get'
timeout 请求的超时时间(ms), 默认为9000
withCredentials 跨域时,是否携带cookie。默认为true(仅dataType为'json'时有效)
headers 自定义的请求头部

Returns

返回Promise,服务端返回的http数据通过then的回调获取

Example

Tida.rop.call('ajax', {
  url: 'http://gw.api.taobao.com/router/rest'
  data: {
    format: 'json'
  },
}).then(function (data) {
  console.log(data);
}, function (err) {
  console.log(err);
});

FAQ

关于此文档暂时还没有FAQ
返回
顶部