<form class="form-horizontal" method="post" id="sponsor" name="sponsor" onsubmit="return ajaxSubmit();" >
<input type="text" class="form-control" id="sponsor_name" name="sponsor_name" placeholder="Enter Name"/>
<input type="submit" class="btn btn-default" name="sponsor_form" value="Register" />
</form>
function ajaxSubmit(){
// fetch where we want to submit the form to
var url = url;
// fetch the data for the form
var email = $('#sponsor #email').val();
// setup the ajax request
$.ajax({
url: url,
method:'POST',
data: {email:email},
success: function(data) {
if(data!=0){
alert('ifenter');
$('#msg_section').html('The email has already registered with '+data+' plan <br/> <button type="button" class="btn btn-default form_sponsor" id="form_sponsor" name="form_sponsor" onclick="submitform()">Click Here to Continue</button>');
$('#msg_section').css('display','block');
$('#form_sponsor').css('display','block');
return false;
}else{
alert('enter');
$('#msg_section').css('display','none');
$('.form_sponsor').css('display','none');
$('#msg_section').html('');
return true;
}
}
});
return false;
}
返回true它假设进入isset($ _ POST [&#39; sponsor_form&#39;])。但它没有任何帮助被接受。这是ajax无法正常工作。