jquery - Having issues to pass datatables js Post method to WebApi controller in list only -


i trying pass whole table data in ajax post webapi 2, , null on server side

datamodel

public class product {     public string id { get; set; }     public string title { get; set; }     public string site { get; set; }     public decimal? value { get; set; } } 

webapi 2 controller

    [route("home/api/active/updatedata")]     public ihttpactionresult updatedata(product product)     {         // code     }      [route("home/api/active/updatealldata")]     public ihttpactionresult updatealldata(list<product> products)     {          // code (products here receives null)     } 

it working fine when passing single row object:

    $('#activelisting tbody').on('click', 'button.color', function() {         var tr = $(this).parent().parent();         var rowdata = table.row(tr).data();          $.ajax({                 method: "post",                 url: "api/active/updatedata",                 data: rowdata             })             .done(function (result) {                 table.row(tr).data(result).draw(false);             }).fail(function (xhr, status, p3, p4) {                 alert(xhr.responsetext);             })             .always(function () {                 // change icon             });     }); 

it not working when trying pass whole table data

    function updatealldata() {         var tabledata = table.rows().data().toarray();         debugger;         $.ajax({             method: "post",             url: "api/active/updatealldata",             //data: json.stringify(tabledata) // ??             data: tabledata             }).done(function (result) {                 // redraw whole table             }).fail(function(xhr, status, p3, p4) {                 alert(xhr.responsetext);             })             .always(function () {                 // change icon         });     } 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -