Jquery post Data没有进入控制器

时间:2012-12-07 03:57:21

标签: jquery ajax asp.net-mvc

我有以下jquery

 $('#example').tableDnD({
    onDrop: function (table, row) {

        alert(JSON.stringify($('#example').tableDnDSerialize()));
        var data = JSON.stringify($('#example').tableDnDSerialize());

        $.post("/admin/ReorderNews", data, function (theResponse) {
            $("#response").html(theResponse);  
        });
    },
    dragHandle: ".dragHandle"
});

以下是示例数据:example[]=&example[]=1&example[]=2&example[]=

当我将数据发布到/admin/ReorderNews/

时,我将表中的信息存储在数据中

如下:

    [HttpPost]
    public ActionResult ReorderNews(string data)
    {


        return Content("ok");
    }

它返回OK。然而,当我调试时,我发现数据是null

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

在post方法中将数据用作{“data”:data},并在actionresult中使用字符串数据。

    $.post("/admin/ReorderNews", {"data":data}, function (theResponse) {
        $("#response").html(theResponse);  
    });

由于

相关问题