我从jQuery ajax请求发送表单细节到一个PHP脚本,得到了一个奇怪的结果。相同的脚本可以在其他地方免费使用。基本上这个表单是使用jQuery.ajax这样提交的:
//if submit button is clicked
$('#form1').submit(function () {
//Get the data from all the fields
var name = $('input[name=name]');
var email = $('input[name=email]');
var con_email = $('input[name=con_email]');
var comments = $('textarea[name=comments]');
//organize the data properly
var data = 'name=' + name.val() + '&email=' + email.val() + '&con_email=' + con_email.val() + '&comments=' + encodeURIComponent(comments.val());
//show the loading sign
$('.loading').show();
//start the ajax
$.ajax({
//this is the php file that processes the data and send mail
url: "process-email/process.php",
//GET method is used
type: "GET",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function () {
//if process.php returned 1/true (send mail success)
if (html==1) {
//hide the form
$('.form').fadeOut('slow');
$('.done').delay(1000).fadeIn('slow');
}
}
});
//cancel the submit button default behaviours
return false;
});PHP脚本正常工作,发送电子邮件并返回1(发送电子邮件),但脚本停在:if(html==1)。我得到这个错误
html is not defined如上所述,完全相同的脚本在其他地方工作正常,但在这里我得到该错误,脚本停止。有人可以帮助了解可能出现问题的位置吗?