Thursday 15 August 2013

jquery - mapping ajax data in c# using object binder -


The following screen shot shows the data I'm sending (in firebug with firefox shown) in the code below Ajax method shows the method of call. Properties of the date and id are correctly populated while calling the server side method call, but there is no value in my array (type of customer type), although the number of client concessions in the post is correct.

Any thoughts? Thank you

Enter image details here

My Controller Method < // P>

  Show public performance (customer request) {. // request.CustomerRequests is correct // request.CustomerRequests [0] .name == blank ?? Customer class:  [DataContract] Public class customer {[database] Public customer request [] Customer request { get receive; Set; } [Datemember] Date of the public date {receive; Set; } // I can see this value [data] public id ID; Set; } // I can see this value} [DataContract] Public class customer configuration {{Database} public string name {get; Set; } [Datamember] public string expression {get; Set; }}   

javascript

  $ ('textarea'). Each (function () {var name = 'name'; var, theExpression = 'expression'; var obj = {'name': theName, 'expression': the expression}; expressionary pash (obz);}); // Close each // Well Posted Data Virus = {'Id': '1', 'Date': '2013-10-10', 'Consumer Protection': $ .makere (expressionArray)};   

I have tried though it does not work.

  JSON.stringify ({customer: val})    

After all, we just have to add a content-type to your call and name it from data to remove it

  $ Ajax ({url: '/ administrator / action', cache: wrong, type: 'post', content type: 'application / jason; charset = utf-8', data: JSON.stringify (viewModel)});   

Please note that:

  • Strict coding is a bad practice for you @ Url.Content ("") or Something like this should be used
  • JSON.stringify can not work with older browsers. You may need to add this link:

No comments:

Post a Comment