【发布时间】:2025-12-20 11:10:06
【问题描述】:
我正在使用 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 中用作数据的一样:
任何帮助将不胜感激!
【问题讨论】:
-
检查您的节点服务器控制台,这应该会提供更多线索。也许 ajax 帖子没有发布您认为的内容
-
我的节点服务器控制台没有抛出任何错误
-
你写的是它返回500,所以它必须在应用程序的快递端。
标签: javascript jquery ajax post