DarthVader
DarthVader

Reputation: 55022

Jquery post Data is not getting to controller

I have the following 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"
});

Here is the sample data: example[]=&example[]=1&example[]=2&example[]=

I m storing the information of table within data, when i post the data to /admin/ReorderNews/

which is as follows:

    [HttpPost]
    public ActionResult ReorderNews(string data)
    {


        return Content("ok");
    }

it returns OK. however while I m debugging i see that data is null.

How can i fix this?

Upvotes: 0

Views: 609

Answers (1)

Sridhar Narasimhan
Sridhar Narasimhan

Reputation: 2653

Try the data as {"data":data} in post method and use string data in actionresult.

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

Thanks

Upvotes: 1

Related Questions