【问题标题】:Getting 400(bad request) error in jquery ajax POST在 jquery ajax POST 中出现 400(错误请求)错误
【发布时间】:2016-03-22 07:02:11
【问题描述】:

我正在尝试使用 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);
    }
})

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

【问题讨论】:

  • 该调用适用于邮递员或其他 ajax 工具?错误是否显示在真实设备或模拟器/浏览器中?

标签: javascript jquery html ajax cordova


【解决方案1】:

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

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

【讨论】:

猜你喜欢
  • 2014-08-02
  • 2013-04-07
  • 1970-01-01
  • 2019-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多