.net - ASP.NET MVC Ajax: Passing an IList from the View to the Controller -


I have to pass the grid lines from the view using the POST controller.

  • String ID
  • String ID
  • String ID
  • I want to read the data from JackGrid and pass the controller to fill it in ILIL.

    I am trying to create data objects to pass Ajax data parameters.

    Here is the JavaScript code:

      $ ("# saveButton"). Click (function () {var returnData = '{'; var currentIDs = $ ('# ListPeople'). GetDataIDs (); if (IDs PEOPLES.AMPH & gt; 0) {for (i = 0; i & lt ; IdsPeople.length; i ++) {// Object data reserved = rate + "people ['+ i +'] .name": '$ (' # list folk '). GetRowData (ID people [i]). Name + ','; ret = ret + '"[' + i + '] address":' $ '(' # list people '). GetRowData (ID people [i]) address +', 'rate = rate + '"People [' + i + '].' ':' $ ('# ListPeople') .Getravatata (id folk people [i]) .ID + ','; // if there are more than one element in it (IDesPepil.Lamban> 1 & amp; amp; amp; amp;; (i + 1) & amp; Lt; i DsPeople.length) {rate = '+', ';}}} rate = rate +'} ';  

    My Ajax function to send:

    < Pre> var url_all = '& lt;% = Url.Action ("SaveData")%> $. Ajax ({type: "post", url: url_all, data: ret, data type: " Jason "," Success ": Work () {Warning (" OK ");}, Error: Action () {Warning (" Error: Check Savvy Data ")}}});

    My Controller:

      Public actions savedData (IList & lt; PeopleHeader & gt; People) use the // // debug to know that "people" variables have any value return Json (right); }  

    The problem I am facing is an error: "System.NotSupportedException: A collection of fixed sizes", and no data is being distributed.

    I think my problem depends on the object ... is there any easy way to process it?

    Thank you in advance,

    The problem is that you have JSON encoded in the action method Posting data, but the action method only accepts the form of encoded data (aka content type: application / www -x-form-urxx).

    I think that if you simply draw the line:

    Data type: "Jason"

    It should work. Or, if you really want to post JSON, you can try JsonValueProvider.


    Comments