如何手动关闭fancybox中的Ajax页面显示? [英] How to close Ajax page display in fancybox manually?

查看:82
本文介绍了如何手动关闭fancybox中的Ajax页面显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在花式框中显示一个Ajax反馈表单,一旦发送反馈(时间延迟为20秒),我就需要关闭花式框.

我的幻想电话是...

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

完成请求后,无论花费多长时间且不依赖20秒超时,这都将关闭对话框.如果您想在响应后 20秒后关闭该框,则可以执行以下操作:

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

要表明您正在提交请求,您可能需要使用showActivity:

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

这篇关于如何手动关闭fancybox中的Ajax页面显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆