I was having a problem with the jQuery .serialize() function and the good news is that I found the answer to this problem.
The Problem
The jQuery .serialize() function was returning “” or nothing. Not what I wanted to say the least. Here was the setup. I was using .serialize() like this:
... $(this).parents('.ARow').serialize() ...
and the xhtml was:
<form class="ARow"> <input class="food_state" size="10" type="text" /> <input id="NewFoodState" type="button" value="Add New Food State" /> </form>
The Answer
The problem was that .serialize() outputted “”. The answer was that if an input does not have a “name” field then .serialize() skips it. Of course that makes sense but sometime simple reasons can be overlooked. Therefore when the xhtml is updated to:
<form class="ARow"> <input class="food_state" name="food_state" size="10" type="text" /> <input id="NewFoodState" type="button" value="Add New Food State" /> </form>
The output of .serialize() becomes, as desired, “food_state: raw”. I hope this helps someone else.
This page is using: [download id="1"]
3 Comments
Much appreciated! I’ve been banging my head against this for a while, this post was exactly what I needed. Thanks!
I’m glad it helped.
you gonna face other problems just use:
.serializeArray() – i used this on http://turizmas.info changing from prototype .serialize to jquery, and it works fine and same as protype serialization.