0

嗨,我有一个 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);
            }
        });

由于我试图给出我的方法的数据没有调用,我希望我以正确的格式编写它,但我仍然无法理解问题是什么,任何人都可以帮助我。

4

1 回答 1

0

在你的代码中

数据:“{Action:'”+“Set”+“',VesselID:'”+“1”+“',VoyageMasterID:'”+“1”+“',StartTerminalID:'”+“1”+“ ',LastTerminalID:" + "" + ",EffectiveStartDate:'" + "09/09/09" + "',EffectiveEndDate:'" + "09/09/09" + "',PreviousVoyageID:'" + "1 " + "',NextVoyageID:'" + "1" + "',DefaultVoyage:'" + "0" + "',状态:'" + "true" + "'}",

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

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

希望能帮到你:)

于 2013-03-26T08:59:29.707 回答