In jquery 1.4.2.ajax, json does not translate correctly

My code worked fine in JQuery 1.3.2, but in 1.4.2 it seems to be broken. What should happen in the message is something like this:

?pks=108;pks=107

Now I get:

?pks[]=108;pks[]=107;

When I look at this code, the JSON object seems fine until it goes into .ajax. Firebug, after receiving a response, indicates that the message was:

Parameters  application/x-www-form-urlencoded
pks[]   108
pks[]   107
Source
pks%5B%5D=108&pks%5B%5D=107

This is not what I got on jQuery 1.3.2. Where do these extra braces come from?

+5
source share
1 answer

JQuery 1.4 has released a change for Nested Serialization Parameterization . On your site:

jQuery 1.4 jQuery.param, , PHP, Ruby on Rails. , {foo: [ "bar", "baz" ]} "foo [] = bar & foo [] = baz".

jQuery 1.3 {foo: [ "bar", "baz" ]} "foo = bar & foo = baz". . , , Ajax ( jQuery.ajaxSettings.traditional ).

[] , , , , , ( , , ).

Edit: , , , , :

// Globally set it to use the old 1.3.* way of doing things.
jQuery.ajaxSettings.traditional = true;

// Enables the 1.3.* way for a single Ajax request only
$.ajax({ data: stuff, traditional: true });
+8

All Articles