IT:AD:JQuery:Libs:SerializeForm

  • Pros:
    • unlike JQuery's Serialize (which produces a string output), serializes things as a Map.
      • ie: This is beneficial for JSON requests.

      * Cons:

    • The fact that it can work from Id's if there is no Name, is not really a plus…
    • Serializes Names with “_” instead of “.” (as keys can't contain “.”) which will cause problems with deserializing nested objects.
    • As it is a key, and not a string, it doesn't serialize Checkboxes as two entries (which is what the MVC framework was expecting), but as a single key with two values separated by comma.

ie, instead of serializing the checkbox and the hidden field that MVC puts in there (with the same name) as:

MyCheckBox=true&MyChecBox=false 

it comes out as:

[MyCheckBox:true,false]

This in turn gets serializes as a form post:

MyCheckBox:true,false

which causes MVC to fail deserialzing it back to the original Model bool property, and so all checkboxes remain false… Not good.

Note that

$('#formid').serializeArray();

returns a Map. Move towards JSON.stringify

  • /home/skysigal/public_html/data/pages/it/ad/jscript/jquery_libs_serializeform.txt
  • Last modified: 2023/11/04 03:26
  • by 127.0.0.1