问题
I am displaying an ajax feedback form in fancy box and i need to close the fancy box once feedback send(with time delay of 20sec).
My fancy box call is...
$("#feedback").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'centerOnScroll': false,
'autoDimensions': true,
'type' : 'ajax'
});
回答1:
Something like this. Modify as needed.
$.post('/YourAjaxRequest', { your ajax data }, function() {
$.fancybox.close();
}, 'json');
This will close the dialog box when the request is finished, no matter how long it takes, and does not rely on a 20 second timeout. If you want to close the box 20 seconds after the response, you could do this:
$.post('/YourAjaxRequest', { your ajax data }, function() {
setTimeout($.fancybox.close, 20000);
}, 'json');
To indicate that you're submitting a request, you may want to use showActivity
:
$.fancybox.showActivity();
$.post('/YourAjaxRequest', { your ajax data }, function() {
$.fancybox.close();
}, 'json');
来源:https://stackoverflow.com/questions/4387914/how-to-close-ajax-page-display-in-fancybox-manually