开发者

How to close Ajax page display in fancybox manually?

开发者 https://www.devze.com 2023-01-30 01:46 出处:网络
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).

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消