im trieing to serialize a complete form. i found the easiest way:
var tmp = $('myForm').toQueryString().parseQueryString();
var req = JSON.decode( tmp );
but it wont work.
i testet only
var tmp = $('myForm').toQueryString()
alert("data " + tmp);
also wont work. it only prints “data ” nothing more..
my form is simple:
<form action="test.php" id="myForm">
<input type="text" name="user">
<input type="text" name="user_name">
<input type="submit" name="user_name_button">
</form>
the javascript code is like:
$('myForm').addEvent( 'submit', function( e )
{
e.stop();
var tmp = $('myForm').toQueryString()
alert("data " + tmp);
})
does anybody has an idea why this didn work ?
Found the error. The submit and one text field had the same name.
See the fixed version here, http://jsfiddle.net/HXsBk/1/