How to close Ajax page display in fancybox manually?
I am displaying an ajax feedback for开发者_开发技巧m 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'
});
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');
精彩评论