Reputation: 1814
Have the following in an fancybox ajax call
$.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();
});
}
}
});
all works fine appart from the closing, tried various variations without sucess.
The timeout above gives me
Error: useless setTimeout call (missing quotes around argument?)
so i tried both
setTimeout('$.fancybox.close()', 1000);
and
setTimeout("$.fancybox.close()", 1000);
to which i get the following error TypeError: $ is undefined
...help !
Upvotes: 0
Views: 897
Reputation: 4165
Try as shown below:
setTimeout(function(){ $.fancybox.close();}, 1000);
Upvotes: 1
Reputation: 9361
Try creation a simple function called "closeMyFancyBox" such as
function closeMyFancyBox() {
$.fancybox.close();
}
Then call that function as setTimeout('closeMyFancyBox', 1000);
Upvotes: 0
Reputation: 1701
setTimeout
expects either a function reference or a string to evaluate. In your case try calling setTimeout
like:
setTimeout(function() { $.fancybox.close(); }, 1000);
Upvotes: 1