gpt4 book ai didi

javascript - jquery ajax POST 中出现 400(错误请求)错误

转载 作者:行者123 更新时间:2023-11-28 06:13:47 26 4
gpt4 key购买 nike

我正在尝试使用 jquery 发送 Ajax POST 请求,但收到 400(错误请求)错误这是我的代码:

$.ajax({
url: "http://192.168.3.118:2244/api/Customer/PostTblCustomer",
type: "POST",
data: {"CustName":"naveen",
"Mobile": 9490429799,
"Email":"naveendodda848@gmail.com",
"Address":"Hyderabad",
"Password":12345,
"PinCode": 50000,
"IsServiceProvider":"false",
"Is_Blocked":"false"},

dataType: "json",
contentType:"application/json",

success: function(data){
alert("success");
alert(data);
console.log(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert("error");
alert(thrownError);

console.log(xhr.status)
console.log(thrownError);
console.log(ajaxOptions);
}
})

我是电话差距新手,请在上面附加的代码中更正我,提前致谢

最佳答案

您可能需要对数据进行字符串化

data: JSON.stringify({"CustName":"naveen", 
"Mobile": 9490429799,
"Email":"naveendodda848@gmail.com",
"Address":"Hyderabad",
"Password":12345,
"PinCode": 50000,
"IsServiceProvider":"false",
"Is_Blocked":"false"}),

关于javascript - jquery ajax POST 中出现 400(错误请求)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36148035/

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