-1
我需要爲intracom創建一個簡單的HTTP GET請求。JSONP Utncaught語法錯誤:意外的令牌
該請求打開了一扇門。如果我在瀏覽器中輸入此URL: http://172.27.1.20/api/switch/ctrl?switch=1&action=on 端口打開並且瀏覽器顯示它。
{
"success" : true
}
我嘗試使用Ajax的腳本發送HTTP GET但控制檯日誌顯示:
ctrl?callback=jQuery1600571…_1473684252251&switch=1&action=on&_=1473685494405:2 Utncaught SyntaxError: Unexpected oken :
function test() {
$.ajax({
url: 'http://172.27.1.20/api/switch/ctrl',
type: 'GET',
data: {switch: 1, action: 'on'},
crossDomain: true,
dataType: 'jsonp',
dataCharset: 'jsonp',
contentType: 'application/json',
success: function (result) {
console.log("OK - RESULT: " + result);
},
error: function (result, error) {
console.log("ERROR - RESULT: " + result + " - TYPE ERROR: " + error);
}
});
}
有人能helpme?
我們e jsonp,因爲我需要從另一個域使用它。 –
如果它有幫助,你可以接受下面的答案嗎? –