【发布时间】:2017-12-07 12:02:47
【问题描述】:
我想用 jsontype
假设我在 5 个文本框中有 5 个字段,4 个文本框正常文本一个字段值本身 json,以便 ajax 抛出错误。如何发送
[![在此处输入图片描述][1]][1]
my.js
function _getTest(){
var data = JSON.stringify($("#formId").serialize());
//alert(data);
$.ajax({
url: "domain.com",
datatype: 'json',
type: "POST",
contentType: 'application/json',
data: data,
success: function(data) {
console.log(data);
},
error: function(result) {
alert(result.responseText);
}
});
}
提交表单后,我得到了这个状态代码:400 错误请求
常规标签 请求网址:http://mycustomurl/com 请求方法:POST 状态码:400 错误请求 远程地址:35.154.113.130:8080 推荐人政策:no-referrer-when-downgrade
[![在此处输入图片描述][2]][2]
预期有效载荷
{
"name": "user",
"mobile": "1234567890",
"email": "my@gmail.com",
"address": "test",
"localityID": 1,
"cityID": 1,
"bookingDate": "2017-12-20",
"timingID": "1",
"paymentType": 1,
"affiliateID": 15,
"key": "test",
"password": "test",
"orderItems": [{
"id": 3,
"quantity": 2
}, {
"id": 4,
"quantity": 5
}]
}
【问题讨论】:
-
你有权访问服务器的日志吗?
-
No this error I got in console HTTP Status 400 - type Status report message description 客户端发送的请求在语法上不正确。
-
@AlivetoDie--Anantsingh 请检查我的问题;不同的是这是不同的
-
@Learning 这就是为什么我不复制您的帖子,只是将其添加为评论
标签: javascript jquery json ajax