December 2016 - Digital Tool Factory blog December 2016 - Digital Tool Factory blog

The 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.

 


31
Dec 16


Written By Steve French

 




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