为了清楚起见,您只想更改fancybox 的内容?
如果是这种情况,那么我建议如下:
$("#messform").submit(function() {
var emailval = $("#contactEmail").val();
var msgval = $("#c_message").val();
var msglen = msgval.length;
var mailvalid = validateEmail(emailval);
var mailvalid = true;
var msgval = $("#c_message").val();
var msglen = msgval.length;
if(mailvalid == true && msglen >= 4) {
// if both validate we attempt to send the e-mail
// first we hide the submit btn so the user doesnt click twice
$("#send").replaceWith("<em>sending...</em>");
$.ajax({
type: 'POST',
url: 'sendmesse.php',
data: $("#messform").serialize(),
success: function(data) {
if(data == "true") {
$("#messform").fadeOut("fast", function(){
$(this).before("<strong>Success! Your feedback has been sent, thanks :)</strong>");
// setTimeout($.fancybox.close(), 1000);
// $('.fancybox').close();
// $.fancybox.close();
setTimeout(function(){ $.fancybox.close();}, 1000);
});
}
}
});
}
// 这部分很重要,因为您使用的是 ajax 帖子,因此您希望忽略正常的表单提交。返回假;}); });