1

I am aware that this topic has been brought up hundreds time but I cannot find any solution in any forum which works:

var rows = $('#grid').jqxGrid('getrows');
var drtyRows = new Array();
for (var i = 0; i < rows.length; i++) {
    if (rows[i].nar1 != 0) {
        drtyRows.push(rows[i]);
    }
}                   
var jsoo = JSON.stringify(drtyRows );
alert(jsoo);  // shows data in jsoo correctly

$.ajax({
    type: "POST",
    cache: false,
    dataType: "json",
    url: "/Employee/Edit",
    contentType: "application/json",
    contentType: "application/json; charset=utf-8",
    traditional: true,
    async: false,
    data: jsoo,
    success: function (data) { alert("came back with Success"); },
    failure: function (errMsg) {
        alert(errMsg);
    }

});

Ajax sends the array to the controller but there are only empty rows in it:

enter image description here

I have checked the posted and stringifyed variable before sending and it seems correct:

enter image description here

Any ideas?

ekad
  • 14,436
  • 26
  • 44
  • 46
Pete
  • 11
  • 1
  • 3
    How does your personmodel class looks like ? – Shyju Aug 25 '16 at 16:14
  • I deleted my answer because it appears "list" has data in it. 7 records, you should add that to the watch list and check it's contents. PName is null probably due to a property mismatch – Neil N Aug 25 '16 at 17:18
  • E.g. this [question](http://stackoverflow.com/questions/13779043/post-json-array-to-mvc-controller) has good answers. HTH – Daniel Dušek Aug 25 '16 at 17:55
  • personmodel looks exactly like the array. A Viewmodel which is annotated with seriazable. PName is a deined string in the model – Pete Aug 25 '16 at 17:56
  • this is exactly the problem. I get a list with 7 records which is correct, but all the fields in the rows are empty, although in the JSon string which I send the content is there. The content of the records disappears on the transfer from ajax to the controller – Pete Aug 25 '16 at 18:03
  • 1
    `var jsoo = JSON.stringify({ list: drtyRows });` (and remove `traditional: true,` and `async: false,` and one of the `contentType` options. –  Aug 25 '16 at 23:45

0 Answers0