繁体   English   中英

Ajax Post 请求返回内部错误 500?

[英]Ajax Post request returns internal error 500?

我正在使用 jQuery 和 Node.js + Express API 制作一个供本地使用的项目。 当我使用邮递员“下订单”时,没有问题:

在此处输入图片说明

当我这样做时,在我看来,与 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);
        }
    });

global_orderSummary 在我使用 console.log 时看起来像这样,看起来与我在 Postman 中用作数据的相同:

在此处输入图片说明

任何帮助将非常感激!

我必须进行这些调整,现在它可以工作了:

type: "post",
url: "http://localhost:3001/roomorder",
data: JSON.stringify ({roomOrderLines: global_orderSummary}),
dataType: "json",
contentType: "application/json",

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM