asp.net mvc - jQuery post with form.serialize() receives null -


when post html.form jquery in following syntax:

$.post('<%: url.action("actionname","controllername") %>',              $("#formname").serialize()); 

the object posted correctly server, if use:

var reason = encodeuricomponent($("#formname").serialize()); $.post('<%: url.action("actionname","controllername") %>',                         { reason: reason }); 

the serialized object null, same result when use encodeuricomponent or without it. need send more parameter data server, why want use second method, can't send serialized object correctly.

it works boxing serialized string [] when posting data:

var reason = $("#formname").serialize(); $.post('<%: url.action("actionname","controllername") %>',                     { reason: [reason] }); 

when checking http fiddler difference in body of post when doing this:

var reason = $("#formname").serialize(); $.post('<%: url.action("actionname","controllername") %>',                     { reason: reason }); 

the body tag held this: reason=type=1&comments=&id=15 not differentiate in variable held. boxing in [] body tag contains: reason%5b%5d=type%3d1%26comments%3d%26id%3d1 correctly encoding posted data.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -