Good afternoon,

On 31/01/10 at 8:13 PM -0800, S.A. Kiehn <[email protected]> wrote:

Found a change in the latest jQuery (1.4.1) from the previous release I used (1.3.2) that affected a Catalyst app of mine.  Regarding form field submissions, jQuery now submits multiple checkbox (or select) values with the variable name followed by the array "[]" brackets (probably to appease PHP).  I had a problem with a previous working app and used firebug to look at my JSON post and found the brackets.

In some of the info about the new version, they talk about the new feature:

<http://jquery14.com/day-01>

Nested param serialization (jQuery.param() Documentation, Commit 1, Commit 2)

jQuery 1.4 adds support for nested param serialization in jQuery.param, using the approach popularized by PHP, and supported by Ruby on Rails. For instance, {foo: ["bar", "baz"]} will be serialized as “foo[]=bar&foo[]=baz”.

In jQuery 1.3, {foo: ["bar", "baz"]} was serialized as “foo=bar&foo=baz”. However, there was no way to encode a single-element Array using this approach. If you need the old behavior, you can turn it back on by setting the traditional Ajax setting (globally via jQuery.ajaxSettings.traditional or on a case-by-case basis via the traditional flag).

So rather than changing the name of params you use, change the behaviour of jQuery instead:

<http://api.jquery.com/jQuery.param/>

    jQuery.ajaxSettings.traditional = true;

Note, I haven't tried the above yet. But I think that's because MyApp uses Params::Nested which effectively normalizes the param names for $c->req, so the extra brackets haven't been an issue.

In either case, I had forgotten about that factoid in the release docco; thanks for the notice.


Charlie

--
   Ꮚ Charlie Garrison ♊ <[email protected]>
   〠 PO Box 141, Windsor, NSW 2756, Australia

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to