c# - Ajax POST not posting list -


i passing data controller through ajax call. following ajax code:

var month_list = []; $('#dojmonths :selected').each(function (i, selecteditem) {   month_list[i] = $(selecteditem).text(); }); var from_month = $("#fromkpamonthpicker").val(); var from_year = $("#fromkpayearpicker").val(); var to_month = $("#tokpamonthpicker").val(); var to_year = $("#tokpayearpicker").val(); $.ajax({   url: '/home/_databyfromto',   type: "post",   data: {     doj_month_list: month_list,     from_month: from_month,     from_year: from_year,     to_month: to_month,     to_year: to_year   },   datatype: "html",   success: function (data) {     $("#divlist").html(data);   } }); 

controller action method:

[httppost] public actionresult _databyfromto(list<int32> doj_month_list, int16 from_month, int16 from_year, int16 to_month, int16 to_year) {   return view(); } 

it working in old code fine. don't know whats problem. because data passing except array of jquery.

to disable deep serialization of objects need set traditional property true.

$.ajax({     url: '/home/_databyfromto',     type: "post",     data: {     doj_month_list: month_list,     from_month: from_month,     from_year: from_year,     to_month: to_month,     to_year: to_year     },     datatype: "html",     traditional: true,     success: function (data) {         $("#divlist").html(data);     } }); 

when set true results in shallow serialization. following link might of help. https://api.jquery.com/jquery.param/


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -