停止的fancybox显示的AJAX页面的关闭?页面、fancybox、AJAX

2023-09-10 21:37:19 作者:幸福向左,我向右

如何停止在的fancybox显示的AJAX页面的结束?

How can I stop the closing of an AJAX page displayed in a fancybox?

<a href="sample.php?name=name1&feedback=feedback1" id="feedback">feedback</a>

的fancybox $ C $ jQuery中...

fancybox code in jquery...

    $("#feedback").fancybox({

        'speedIn'   :   600,
        'speedOut'  :   200,
        'centerOnScroll':   false,
        'autoDimensions':   true
        'type'          : 'ajax',
        });

sample.php页面将显示在的fancybox。一旦用户点击sample.php提交按钮。的fancybox关闭。我需要提交反馈表后进行延迟关闭(sample.php)

sample.php page will be displayed in fancybox. once user click submit button in sample.php. fancybox closes. i need to make delay in closing after submitting feedback form(sample.php)

推荐答案

您没贴code所以我只能猜测:

You didn't posted code So I can only guess:

您可以添加此选项:

showCloseButton: false // this will hide the close button
hideOnContentClick: false // this will not close fancybox when clicked inside
hideOnOverlayClick: false // this will not closefancyvox when clicked outside

您可以通过调用也可手动关闭的fancybox $。fancybox.close

You can also manually close fancybox by calling $.fancybox.close

您可以检查更多的 API文档

希望它的你所需要的。

更新:

要能够关闭手动的fancybox表后提交需要发表Ajax和密切的fancybox成功或失败使用的形式' $。fancybox.close

To be able to close manually fancybox after form submit you need to post the form by ajax and close fancybox on success or failure using '$.fancybox.close'

您可以将AJAX绑定到你的表单是这样的:

You can bind the ajax to your form like this:

$('#yourForm').bind('submit', function() {
  $.ajax({
  url: 'yourpage.php',
  success: function(data) {
    if (data == 'Error') { alert('An error occurred')}
    else { $.fancybox.close }
  }
});

});

检查 jQuery的文档阅读更多关于AJAX()函数,并做一些搜索在官方的fancybox支持小组了解详情。

Check the jQuery docs to read more about the ajax() function and do some search in the official fancybox support group for more information.