ajax post请求返回内部错误500?

dced5bon  于 2021-09-23  发布在  Java
关注(0)|答案(1)|浏览(308)

我正在使用jquery和node.js+expressAPI制作一个本地使用的项目。当我使用 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);
        }
    });

全局_ordersummary在i console.log中显示如下,与我在postman中用作数据的内容相同:

任何帮助都将不胜感激!

9jyewag0

9jyewag01#

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

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

相关问题