I am not so good at JavaScript nor jQuery, but I try to learn it. I am creating a contact form with ajax sending, honeypot and fancybox. I am almost done, but I have feeling, that event success in ajax does not work. Here is part of code:
$.ajax({
type: 'POST',
url: '../data/sendmessage.php',
data: $("#contactForm").serialize(),
success: function (data) {
if (data === "true") {
$("#contactForm").fadeOut("fast", function () {
$(this).before("<p><strong>Thank you for message</strong></p>");
setTimeout("$.fancybox.close()", 1000);
});
}
}
});
I thought, it will show the message and then close fancybox, but it doesn't. Can somebody help me to understand, what am I doing wrong? ...I hope this part of code is enough, if not, I will be glad to add whole the script, but that should work OK.