【发布时间】:2011-05-31 09:04:08
【问题描述】:
我有这样的代码。
<html>
<head>
<title>Captcha With Refresh Feature</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function check1(){
var search_val=$("#security_code").val();
if(search_val == ''){
alert("Please enter code");
return false;
}else{
$.ajax({
type: "POST",
url: "find.php",
data: "search_term="+search_val,
success: function(msg){
if(msg == 'failure'){
document.myform.submit();
}else{
alert("Please enter correct code");
return false;
}
}
});
}
return false;
}
}
</script>
</head>
<body onLoad="new_captcha();">
<form action="check.php" method="post" name="myform" id="myform" onSubmit="return check1()">
<table>
<tr>
<td> </td>
<td><img border="0" id="captcha" src="image.php" alt="">
<a href="JavaScript: new_captcha();"><img border="0" alt="" src="refresh.png" align="bottom"></a></td></tr>
<tr><td>Name</td><td><input type="text" name="u_name" id="u_name" /></td></tr>
<tr>
<td>Security Code:</td>
<td><input type="text" name="security_code" id="security_code">
</td><td><input type="submit" name="submit" value="Check"></td> <td><label id="security_code_error"></label><label id="security_code_error1"></label></td></tr> </table>
</form>
</body>
</html>
我的 ajax 响应要么成功,要么失败。 我可以提醒并检查我的 ajax 响应。 现在,我在提交表单时遇到问题。
我收到以下错误: document.myform.submit 不是函数
如果响应成功,如何强制或使我的表单提交。 你能帮我解决这个问题吗?
谢谢 - 韩
【问题讨论】: