Ajax Post 请求 returns 内部错误 500?
Ajax Post request returns internal error 500?
我正在使用 jQuery 和 Node.js + Express API 制作供本地使用的项目。
当我使用 Postman“下订单”时没有问题:
当我这样做时,在我看来,与 jQuery 相同,我收到内部服务器错误 500:
$.ajax({
type: "post",
url: "http://localhost:3001/roomorder",
data: {
roomOrderLines: global_orderSummary,
},
dataType: "json",
success: (placeOrderResult) => {
$('#appContent').html(`success!`);
},
error: (xhr, ajaxOptions, thrownError) => {
global_setError("An error occurred. / "+xhr.status+" / "+thrownError);
}
});
当我 console.log 它时 global_orderSummary 看起来像这样,看起来与我在 Postman 中用作数据的相同:
如有任何帮助,我们将不胜感激!
我必须进行这些调整,现在可以了:
type: "post",
url: "http://localhost:3001/roomorder",
data: JSON.stringify ({roomOrderLines: global_orderSummary}),
dataType: "json",
contentType: "application/json",
我正在使用 jQuery 和 Node.js + Express API 制作供本地使用的项目。 当我使用 Postman“下订单”时没有问题:
当我这样做时,在我看来,与 jQuery 相同,我收到内部服务器错误 500:
$.ajax({
type: "post",
url: "http://localhost:3001/roomorder",
data: {
roomOrderLines: global_orderSummary,
},
dataType: "json",
success: (placeOrderResult) => {
$('#appContent').html(`success!`);
},
error: (xhr, ajaxOptions, thrownError) => {
global_setError("An error occurred. / "+xhr.status+" / "+thrownError);
}
});
当我 console.log 它时 global_orderSummary 看起来像这样,看起来与我在 Postman 中用作数据的相同:
如有任何帮助,我们将不胜感激!
我必须进行这些调整,现在可以了:
type: "post",
url: "http://localhost:3001/roomorder",
data: JSON.stringify ({roomOrderLines: global_orderSummary}),
dataType: "json",
contentType: "application/json",