[英]CORS using jQuery 1.8.3 vs 1.9.1
我正在嘗試使用CORS進行PATCH / POST。 以下代碼在jQuery 1.9.1上有效,但在1.8.3上無效。
var settingsB = {
"async": false,
"crossDomain": true,
"url": "https://wmmr85ap13.execute-api.us-west-2.amazonaws.com/dev/customer/" + m,
"method": "PATCH",
"headers": {
"content-type": "application/json"
},
"data": JSON.stringify({isFirstLogin: "false"})
}
$.ajax(settingsB).done(function (response) {
console.log(response);
});
在jQuery 1.8.1上,我得到:
XMLHttpRequest無法加載https://wmmr85ap13.execute-api.us-west-2.amazonaws.com/dev/customer/jvthales@gmail.com?{%27isFirstLogin%27:%20false%20 }。 對預檢請求的響應未通過訪問控制檢查:請求的資源上不存在“ Access-Control-Allow-Origin”標頭。 因此,不允許訪問來源' http://emporiodacerveja.vtexcommercestable.com.br '。 響應的HTTP狀態碼為400。
我猜想由於jQuery 1.9.1可以在服務器上正確配置CORS!
使用1.9.1和1.8.3版本進行發布/修補時有什么區別嗎?
編輯:請參見下面的1.9.1與1.8.3調用之間的區別:
需要設置類型和xhrFields
$.ajax({
type : "PATCH", //replaced my method in 1.9
url: cross_domain_url,
xhrFields: {
withCredentials: true
}
});
method
參數是在jQuery 1.9.0中添加的。
方法
(默認:“ GET”)
類型:字符串用於請求的HTTP方法(例如“ POST”,“ GET”,“ PUT”)。 (添加的版本:1.9.0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.