我有一个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