gpt4 book ai didi

javascript - Ajax 请求不起作用?

转载 作者:行者123 更新时间:2023-12-02 15:15:31 25 4
gpt4 key购买 nike

当我尝试 POST 我的 JSON 时,我看不到任何请求,而且我的本地服务器甚至没有收到这些调用。

这是我的ajax部分

function callserver(){
var markers = {"regDate" : 1451330123000, "specialities" : " ", "isActive" : true, "mobileNo" : "876876","id" : 0, "completed" : false,"mcname" : "", "password" : "hgh","role" : "SuperAdmin,Consultant","logins" : [],"email" : "testtestets@test.com","name" : "regcg","organization" : "hghjg"};
alert(markers);
$.ajax({
type: "POST",
data:markers,
headers: {
'Accept':'application/vnd.company.productname-v1+json',
'X-PD-Authentication':'42</B7Tg8o5C7`7<7Ar0?]pJs`@Noplt>I1m>QYQn[v=osDl:unWyx`SYqBK@0?w',
'Content-Type':'application/json'
},
dataType: "json",
url: "http://x.x.x.x:9001/users",
success: function(data) {
alert("success");
},
error: function () {
alert("failure");
}
});

}

直到alert(markers);正在工作,但在那之后

我没有收到“成功”或“失败”警报。控制台截图

enter image description here

enter image description here

请帮助我

最佳答案

由于您是 not ready to show the full HTML ,看起来您正在使用另一个带有 jQ​​uery 的库,因为 jQuery works 。因此,请将所有 $ 更改为 jQuery:

function callserver(){
var markers = {"regDate" : 1451330123000, "specialities" : " ", "isActive" : true, "mobileNo" : "876876","id" : 0, "completed" : false,"mcname" : "", "password" : "hgh","role" : "SuperAdmin,Consultant","logins" : [],"email" : "testtestets@test.com","name" : "regcg","organization" : "hghjg"};
alert(markers);
// Change here
jQuery.ajax({
type: "POST",
data:markers,
headers: {
'Accept':'application/vnd.company.productname-v1+json',
'X-PD-Authentication':'42</B7Tg8o5C7`7<7Ar0?]pJs`@Noplt>I1m>QYQn[v=osDl:unWyx`SYqBK@0?w',
'Content-Type':'application/json'
},
dataType: "json",
url: "http://x.x.x.x:9001/users",
success: function(data) {
alert("success");
},
error: function () {
alert("failure");
}
});
}

关于javascript - Ajax 请求不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34509456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com