我编写了这个代码,它应该使用jQuery和iframe提交注册表单。
Javascript
<script type="text/javascript">
$(document).on('click', '#reg_form_sub', function(event) {
var error_message_lgn = $("#reg_frame").contents().text();
$('#reg_error').text(error_message_lgn);
});
</script>
<iframe name="reg_frame" id="reg_frame" style="display:none;" src="register.php"></iframe>
<table>
<tr>
<td>
<p id="reg_error"></p>
</td>
</tr>
<tr>
<td><input type="email" name="reg_email" id="reg_form_input" placeholder="Email"></td>
</tr>
<tr>
<td><input type="password" name="reg_pass" id="reg_form_input" placeholder="Password"></td>
</tr>
<tr>
<td><input type="password" name="reg_pass_confirm" id="reg_form_input" placeholder="Confirm password"></td>
</tr>
<tr>
<td><input type="submit" name="reg_submit" id="reg_form_sub" value="Send me a confirmation email"></td>
</tr>
</table>
</form>
这是一种工作,但当我第一次点击按钮,什么都没有发生。
当我第二次从PHP获得回显时(脚本提交表单,它创建帐户等,但只有在第二次单击之后才能得到回显)。
发布于 2017-12-11 15:53:00
我刚加了负载,现在起作用了
$(document).on('click', '#reg_form_sub', function(event) {
$('#reg_frame').on("load", function() {
var error_message_lgn = $("#reg_frame").contents().text();
$('#reg_error').text(error_message_lgn);
});
});
发布于 2017-12-13 06:27:49
首先,没有表单标记。如果计划保存数据的“使用”按钮,请单击“函数”。
$("button_id_name").click(function(){});
https://stackoverflow.com/questions/47755359
复制相似问题