I just upgraded my jQuery from 1.3.2 to 1.4.2, and I think it's giving开发者_运维百科 me some issues. I have a $.post()
function that calls a controller method and passes along some data that I format like so:
$.post(url, { arrayParam: myArray, param2: false }, someCallback, 'html');
In Firebug, the POST says the parameters in 1.3.2 look like this:
arrayParam: 100
arrayParam: 101 (etc..)
But for 1.4.2 they look like this:
arrayParam[]: 100
This is breaking my controller which is expecting a List<Int32>
for arrayParam
(and is causing some JSON issues around the codebase). Is there a way around this without either reverting back to 1.3.2 or reprogramming all of my controllers??
Thanks
As of jQuery 1.4, the $.param() method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by setting jQuery.ajaxSettings.traditional = true;
.
jQuery's ajax methods use $.param() on the data that is passed in.
See jquery param for more info.
Here is your fix:
jQuery.ajaxSettings.traditional = true;
精彩评论