JSon数据错误

本文关键字:错误 数据 JSon | 更新日期: 2023-09-27 18:05:58

嗨,我有一个Ajax Json调用的代码是

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Voyage.aspx/VoyageVessel_Set",
            data: "{Action:'" + "Set" + "',VesselID:'" + "1" + "',VoyageMasterID:'" + "1" + "',StartTerminalID:'" + "1" + "',LastTerminalID:" + "" + ",EffectiveStartDate:'" + "09/09/09" + "',EffectiveEndDate:'" + "09/09/09" + "',PreviousVoyageID:'" + "1" + "',NextVoyageID:'" + "1" + "',DefaultVoyage:'" + "0" + "',Status:'" + "true" + "'}",
            async: true,
            dataType: "json",
            success: function (data) {
                try {
                    alert("Success for ADD button");
                    //  $('#dvVesselTaggerInfo').html(html);
                } catch (ex) {
                    alert(ex);
                }
            },
            error: function (msg) {
                alert(error);
            }
        });

因为我试图给我的方法的数据不调用,我希望我已经写在正确的格式,但我仍然不能理解是什么问题,可以有人帮助我。

JSon数据错误

你的代码

数据:"{行动:"+"设置"+",VesselID: " + " 1 " + ", VoyageMasterID: " + " 1 " + ", StartTerminalID: " + " 1 " + ", LastTerminalID :" + " + ", EffectiveStartDate:"+"09/09/09"+",EffectiveEndDate:"+"09/09/09"+",PreviousVoyageID: " + " 1 " + ", NextVoyageID: " + " 1 " + ", DefaultVoyage:"+"0"+",状态:真正的"+" " + "'}",

一般来说,json数据中的每个键和值都应该有引号,例如:

{"Action" : "add", "VesselID", "1"}  

希望能帮到你:)