![](/img/trans.png)
[英]xmlhttprequest cannot load response URL. for preflight has invalid http status code 405 for $http.delete
[英]XMLHttpRequest cannot load URL. Response for preflight has invalid HTTP status code 404
我已經從我的.aspx頁創建了一個CORS請求。 我的Ajax請求如下。
$.ajax({
method: 'POST',
url: "https://api.kraken.io/v1/url",
data: JSON.stringify('{"auth": {"api_key:"' + api_key + '","api_secret:"' + API_Secret + '"},"url:"+ "http://test.pw.com/ScreenShots/3C65B6.jpg","callback_url:"+ "http://test4.pw.com/Admin/TaskAndProjectSearch.aspx","json": true}'),
crossDomain: true,
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
},
success: function (result) {
console.log(result.d);
},
error: function (req, status, error) {
}
});
我正在使用IIS8,並且已通過在web.config中添加以下內容來啟用CORS
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type, Access" />
</customHeaders>
</httpProtocol>
</system.webServer>
我仍然收到以下錯誤。 XMLHttpRequest無法加載url。 飛行前響應具有無效的HTTP狀態代碼404。 有任何人對此有任何想法。我需要盡快解決。 請幫忙。 提前致謝
幾分鍾前,我也遇到了同樣的錯誤。 原來我的API發布到的URL錯誤。 當我解決該問題時,一切正常。 確保您的網址正確。
您的web.config內容不正確。 您應該在</system.webServer>
之前關閉<httpProtocol>
標記。 沒有那個,您的應用程序甚至無法啟動...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.