使用AJAX将参数发送到API

时间:2018-05-16 02:23:51

标签: javascript jquery ajax

所以我想执行以下操作。招摇是这样的: enter image description here

我在.js中完成了以下操作:

  static performAction(id, param, actionUrl) {
  return $.ajax({
     url: api.devices.url + id + actionUrl,
     method: "PUT",
     dataType: "json",
     timeout: api.timeout,
     data: param});
 } 

    ...
    //inside a function
    var act = "/setTemperature";
    var temp = "19";
    var arr = [temp];
    var pp = JSON.stringify(arr);

       //Perform action apparently fails and returns null                       
   api.devices.performAction(item.id, pp, act).done(function(data){ 
           status.nextElementSibling.innerHTML = nueva_temp + "°C"; //works ok
    });

所以我假设格式错了?为什么呢?

0 个答案:

没有答案