[英]Chrome Error - Resource interpreted as Script but transferred with MIME type text/plain
[英]ajax error: Resource interpreted as Script but transferred with MIME type text/json:
我正在嘗試使用JSONP
從服務器獲取數據,但在控制台中JSONP
收到警告
Resource interpreted as Script but transferred with MIME type text/json:
以下是我的ajax電話
var loginData = {
"strUniqueID" : "123",
"UserName" : "UserName",
"Password" : "Password"
};
$.ajax({
url: http://domain.com,
type: "POST",
data: {'data':$.toJSON(loginData)},
contentType: "text/plain",
dataType: "jsonp",
jsonpCallback: 'jsonCallback',
success: function(data) {
console.log('Success');
console.log(data);
},
error: function(jqXmlHttpRequest, textStatus, errorThrown) {
// Display the error.
console.log('Error: ' + textStatus);
console.log('Error thrown: ' + errorThrown);
}
});
由於收到警告,我也收到此錯誤
Uncaught SyntaxError: Unexpected token :
在Firefox中,顯示為
SyntaxError: missing ; before statement
這是因為我的數據沒有以正確的格式帶回嗎?
如果我使用參數打開URL,則可以正確獲得響應
{"response":"SESSION ID"}
但是我也從ajax調用中得到一個錯誤
Error: parsererror
Error thrown: jsonCallback was not called
我已經花了幾個小時動腦筋,我很沮喪!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.