You can do something like this:
$('#myform').submit(function(e) {
e.preventDefault();
var form = $(this);
form.children('input').each(function() {
form.data($(this).attr('name'), $(this).attr('value'));
});
});
Change . There were some errors ( getChildren" children, myform" #myform) in my code . Now I fixed it.
Please note that this script does not submit the form. You can add some great ajax to do this :)
http://docs.jquery.com/Ajax/serialize
. jQuery : form.serialize(). :
<form id="myForm">
<input type="radio" value="A" name="foo" checked="checked" /> A<br />
<input type="radio" value="B" name="foo" /> B
<input type="text" name="bar" value="Bla bla" />
</form>
<script>
var queryString = $('#myForm').serialize();
</script>