我有一个页面,我打电话,有一个表单提交ajax调用。当该函数被第二次调用时,它在ajax调用数据中具有原始数据。第二次调用serialize()值错误
test_form.php
function form($a, $b) {
?>
<form name="myform" id="myform">
<input type="text" id="a" name="a" value="<?php echo $a; ?>" />
<input type="text" id="b" name="b" value="<?php echo $b; ?>" />
</form>
<script>
console.log($("#myform").serialize());
</script>
<?php
}
这是随后从一个单独的文件名为:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="/P3Live/_includes/css/gametypes.css">
<link rel="stylesheet" type="text/css" href="/P3Live/_includes/css/tables.css">
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script src="/P3Live/_includes/js/general_functions.js"></script>
</head>
<?php
error_reporting(E_ERROR);
include_once("test_form.php");
form("firstA", "firstB");
echo "step # 1 should be started <br />";
form("secondA", "secondB");
echo "step # 2 should be started <br />";
?>
当第二个文件
我只序列化部分在这里简化了这个被激发,结果是:
HTML页: ˚F irstA(输入框1)firstB(输入框2) 步骤#1中应该开始
第二A(输入框1)secondB(输入框2) 步骤#2应开始
控制台: 一个= firstA & b = firstB A-firstA & b = firstB
你会发现输入字段是正确的,但在底部的序列化的数据是没有的。它显示两个结果第一次调用的相同序列化数据。我尝试发布截图,但没有声望点。
任何帮助将不胜感激。
哇..我现在觉得愚蠢。谢谢 –