![](/img/trans.png)
[英]Error: MIME type ('application/json') is not executable, and strict MIME type checking is enabled with YQL statements?
[英]AJAX error message on Chrome, MIME type checking is enabled
每次我運行此代碼時,都會收到以下錯誤消息:
index.html:1拒絕從' http://quotesondesign.com/wp-json/posts?callback=jQuery321021689358047216856_1511579115978 '執行腳本,因為其MIME類型('application / json')無法執行,並且嚴格的MIME類型檢查是啟用。
$.ajax({
url: "http://quotesondesign.com/wp-json/posts",
type: "GET",
dataType: 'jsonp',
cache: true,
success: function (data, status, error) {
console.log('success', data);
}
});
我找不到解決方案,請幫助我解決此錯誤。
您正在告訴jQuery將其讀取為JSONP。
JSON和JSONP不同。
您需要更改服務器以使用JSONP進行響應,或者更改JavaScript以使用JSONP。
如果更改客戶端以使用JSON,則還需要更改服務器(quotesondesign.com)以提供CORS標頭,該標頭賦予瀏覽器忽略相同原點策略的權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.