我有一個ARC由客戶端設置,一切似乎在ARC和後端是工作好了,但我看不出什麼,我在jQuery的高級REST客戶端的jQuery請求
做錯了這裏的在ARC測試
這裏是我的jQuery代碼
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>
let urlBase = 'http://54.210.29.209';
let urlEnterEmail = '/api/v1/users/checkEmail';
$(document).ready(function() {
$.ajax(
{
method: "POST",
crossDomain: true,
url: urlBase + urlEnterEmail,
xhrFields: {withCredentials: true},
headers: {
"Access-Control-Request-Headers": "x-requested-with",
"Content-Type": "application/json",
"Platform": "web",
"Build": 2
},
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: {"email": "[email protected]"}
}
)
.done(function (response) {
console.log('done!');
console.log(response);
})
.fail(function (xhr, status) {
console.log('fail!!!');
//console.log(xhr);
console.log(status);
});
});
</script>
</head>
<body>
</body>
</html>
最後,錯誤
我讀了一點關於CORS,但它不工作。我發現的資源如下,但我不知道我是否是有問題或後端代碼的人。
How to get a cross-origin resource sharing (CORS) post request working
https://www.html5rocks.com/en/tutorials/cors/
而你沒有收到任何錯誤,也沒有迴應? – adeneo
嘗試串化您的數據 - 數據:JSON.stringify({「email」:「[email protected]」}) – Shane
@Shane noup ...不使用stringify :( – pctroll