How to close Ajax page display in fancybox manually?

為{幸葍}努か 提交于 2019-12-11 16:34:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!