How to fix problems with missing form values on jquery serialization - Digital Tool Factory blog How to fix problems with missing form values on jquery serialization - Digital Tool Factory blog

How to fix problems with missing form values on jquery serialization

So – I was toiling away on some client side code, and noticed that a dropdown value was not being sent on a post command.  After much rending of garments and gnashing of teeth I figured it out.  I was setting the value with a .val(“something” command) – then doing the post.  It would seem that if you are doing that immediately the value is not quite in the dropdown yet (probably some DOM thing) and rather than send a null value it will omit the dropdown entirely on the serialization, and not send it on the post.

The solution is to

  1. manually add the value as an option in the dropdown
  2. then set that value with the .val() command
  3. then serialize the form
  4. then do the post.

 

 

Written By Steve French

 

Leave a Reply

Your email address will not be published. Required fields are marked *






Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.