我正在使用 jquery 提交表单,并且在表单提交后似乎无法阻止页面重新加载。
我当前的代码如下所示:
HTML:
<form class="form-horizontal" method="post" action="#" name="basic_validate" id="basic_validate" />
<div class="control-group">
<label class="control-label">Image Path</label>
<div class="controls">
<input type="text" name="imagepath" id=imagepath />
</div>
</div>
<div class="form-actions">
<input type=button value="Send" id="sendemailbtn" class="btn btn-primary" />
</div>
</form>
jQuery:
$("#sendemailbtn").click(function(e) {
e.preventDefault();
$("#basic_validate").submit();
if ($("#basic_validate").children('.control-group').hasClass('error')) {
return false;
} else {
$.post('send_email.php', $("#basic_validate").serialize(), function(data) {
// I see output on the server side but never hit this area after the submission,
console.log(data);
}, "json");
}
});