我从表单标签、添加姓名、年龄、电话号码、简历、输入框和验证码开始,但无法通过ajax将表单发送到将发送邮件的php文件。当我发送邮件时,屏幕会刷新**
<form action="#" name="MYFORM" id="MYFORM">
<label>Name</label>
**then i put other labels**
<input name="name" size="30" type="text" id="name">
<br clear="all" />
<label>Email</label>
<input name="email" size="30" type="text" id="email">
<br clear="all" />
<div id="wrap" align="center">
<img src="get_captcha.php" alt="" id="captcha" />
<br clear="all" />
<input name="code" type="text" id="code">
</div>
<img src="refresh.jpg" width="25" alt="" id="refresh" />
<label> </label>
<input value="Send" type="submit" id="Send">
</form>发布于 2012-09-12 18:59:44
您可以使用文件get_captcha.php中的会话来存储验证码的值,当您提交代码时,会将用户输入的验证码的post值与会话中保存的值进行匹配。
发布于 2012-09-12 19:00:17
假设您正在寻找ajax表单提交
$.ajax({
type:'POST',
url: 'yourphpfile.php',
data:$('#formid').serialize(),
success: function(response)
{
// do what ever you want with the repose
}
});在php文件中,通过比较会话中生成和存储的captcha值来指定captcha的验证。如果captcha失败,则根据您得到的响应使用javascript显示错误
https://stackoverflow.com/questions/12386581
复制相似问题