[英]i want to post the json data and get the response data
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<script>
var SendInfo= { SendInfo: [{"dataKey":"1013"}]};
$.ajax({
type: 'post',
url: '/getData',
data: JSON.stringify(SendInfo),
contentType: "application/json",
traditional: true,
success: function (data) {
console.log(data);
}
});
</script>
</body>
</html>
i am parsing the json data but i am getting the 500 server error but everything seems to work fine in postman plese suggest any changes 我正在解析json数据,但出现500服务器错误,但在邮差中一切正常,建议进行任何更改
Have you checked the request you are sending and compared the ajax request to the postman request on the server side? 您是否检查了要发送的请求并将ajax请求与服务器端的邮递员请求进行了比较?
You seem to be sending two different JSONs, in your ajax code you have { SendInfo: [{"dataKey":"1013"}]}
and in your postman request you have just {"dataKey":"1013"}
. 您似乎正在发送两种不同的JSON,在ajax代码中,您有{ SendInfo: [{"dataKey":"1013"}]}
而在邮递员请求中,您只有{"dataKey":"1013"}
。 These are different objects and your back end might not understand them both. 这些是不同的对象,您的后端可能无法同时理解它们。
只有您需要在发帖请求中发送此信息。
var SendInfo= {"dataKey":"1013"};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.