我已经开发了一个用于检查家里所有智能设备的graphich接口,但是当我尝试对shelly进行ajax调用以检查设备状态时,总是会出错。如果我使用postman ,我就能够得到json结果,但是当在ajax中进行相同的调用时就不能了。
我使用jQuery3.6.1版本,并且我的设备中的身份验证被禁用。
文档是:https://shelly-api-docs.shelly.cloud/gen1/#shelly-motion-2
你能帮帮我吗?
与邮递员的ajax调用:

这是我的密码:
function getMovementStatus(obj) {
//http://192.168.68.103/status
var url = protocol + '://' + obj.ip + '/status';
var settings = {
"url": url,
"method": "GET",
"timeout": 0,
"contentType": 'application/json'
};
$.ajax(settings)
.done(function (response) {
console.log(response);
})
.fail(function (request, error) {
console.log(error);
});
}发布于 2022-11-05 06:07:17
protocol字段来自哪里?我在代码中没有看到protocol字段的任何声明。将这一行添加到ajax函数并尝试- var protocol = 'http'。
https://stackoverflow.com/questions/74325234
复制相似问题