hankknight
asked on
jQuery: Post serialized form data with two extra fields
Using jQuery, I want to post all the data contained in #testform as well as two additional values.
This does NOT work:
This does NOT work:
$.post("test.php", xyz: "1", qrs: "2", $("#testform").serialize());
Whats an example value of #testform
For example :
$.post("test.php", $("#testform").serialize() + "xyz=1&qrs=2" );
I miss an "&" :
$.post("test.php", $("#testform").serialize() + "&xyz=1&qrs=2" );
Test page :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script language="javascript">
$(document).ready(function() {
alert( $("#testform").serialize() + "&outside1=" + $("[name='outside1']").val() + "&outside2=" + $("[name='outside2']").val() );
});
</script>
</head>
<body>
<form id="testform">
<input name="inside" value="in"/>
</form>
<input name="outside1" value="out1" />
<input name="outside2" value="out2" />
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points!