我在.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
});
所以我假设格式错了?为什么呢?