Is jQuery 1.4's new behavior a bad design choice? -


This is a bit of rant, but this is also a very natural question. JQuery has changed the AJAX Ultimate Serialization in the following way:

jQuery 1.4 jp. Support for nested param serialization using the popular approach by PPA has been added, and supported by Ruby on Rail. For example, {foo: ["bar", "baz"]} will be sorted as "foo [] = bar & amp; foo [] = baz".

Did you catch it?

You call your parameter foo . JQuery now changes the name of foo [] behind your code if the value of foo is an array is because some PHP-routers and Rubyists have changed the name of the third party API Is expected.

Call me an old way, but when I put something in some map, with the key x , find me the value under x are supposed to. Or at least this is the default behavior with an optional override.

Even the documentation agrees with me:

If the value is an array, then jQuery sorts many values ​​with the same key i.e. {foo : ["Bar1", "bar2"]} '& amp; Foo = bar1and Foo = bar2 '.

Am I correct in thinking that this is just a wrong decision call from the JQuery team?

This is actually to fill a large inconsistency, if your deserializer conference

Older:

  • Foo: "bar"

    Maps "bar" for "foo = bar" .

  • foo: ["bar"] < for "foo = bar" map foo: "bar" .
  • foo: ["bar", "baz"> foo: ["bar", " foo = bar and foo = baz" ] . map

    New:
    • foo: " Bar " Foo:" bar ".
    • foo: ["bar"] map to "foo [] = bar" map .
    • foo: ["bar", "baz"] map to "foo [] = bar & amp; [foo: [" bar ", "Baz"] .

    And now everything roundtrips well and you do not have to worry about getting array data or non-array data, this Depending on how many elements were there, for maximum elegance, foo: [] must be ordered for foo [] (no value) , Which indicates the 0-saw list, but jQuery 1.4 does not do it. Should :)


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -