【发布时间】:2020-02-29 23:46:51
【问题描述】:
<script>
$.ajax({
type: "POST",
url: "http://localhost:3000/xot/us/confirm",
crossDomain: true,
dataType : 'json',
contentType: "application/json; charset=utf-8",
data:JSON.stringify({
username:"User"
}),
success: function(result, status, xhr) {
console.log(result.address1);
},
error: function(xhr, status, error) {
console.log(error);
}
})
</script>
【问题讨论】:
-
那么错误是来自服务器端还是客户端?跨域调用,所以您启用了 CORS?
crossDomain: true,通常是 JSONP -
请提问,不要只贴代码
-
数据要么是格式错误的 JSON,要么根本不是 JSON。
标签: javascript node.js mongodb promise