jquery异步对话框

发布于 2024-12-05 09:09:02 字数 897 浏览 0 评论 0原文

jquery 模式对话框是异步的吗?

$('.triage').click(function() {

                 $("#dialog-modal").dialog({
                        position: [175, 175],
                        draggable: false,
         height: 140,
         modal: true

            });
        });

        $.ajax(
                 {
                 type: "POST",
                 data: [],
                 dataType: "json",
                 contentType: "application/json; charset=utf-8",
                 url: "ReferralAutoTriage.asmx/RunTriageReferrals",
                 success: function(response) {
                      $("#dialog-modal").dialog('close')                               

                },
                failure: function(response) {
                                        }
            });


    });

如果对话框是同步的,我需要将其设为异步,这样我就可以在显示对话框时处理 ajax 调用,并在完成后关闭。谢谢。

Are the jquery modal dialogs asynchronous?

$('.triage').click(function() {

                 $("#dialog-modal").dialog({
                        position: [175, 175],
                        draggable: false,
         height: 140,
         modal: true

            });
        });

        $.ajax(
                 {
                 type: "POST",
                 data: [],
                 dataType: "json",
                 contentType: "application/json; charset=utf-8",
                 url: "ReferralAutoTriage.asmx/RunTriageReferrals",
                 success: function(response) {
                      $("#dialog-modal").dialog('close')                               

                },
                failure: function(response) {
                                        }
            });


    });

If the dialog is synchronous I need to make it asynchronous, so I can process ajax call while displaying dialog and close after I am done with it. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苯莒 2024-12-12 09:09:02

使用 beforeSend/complete 事件来显示/隐藏对话框。

$('.triage').click(function() {
    $.ajax({
        type: "POST",
        data: [],
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        url: "ReferralAutoTriage.asmx/RunTriageReferrals",
        beforeSend: function() {
            $("#dialog-modal").dialog({
                position: [175, 175],
                draggable: false,
                height: 140,
                modal: true
            });
        },
        success: function(response) {
            // whatever
        },
        failure: function(response) {
            // whatever
        },
        complete: function() {
            $("#dialog-modal").dialog('close');
        }
    });
});

Use the beforeSend/complete events to display/hide your dialog.

$('.triage').click(function() {
    $.ajax({
        type: "POST",
        data: [],
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        url: "ReferralAutoTriage.asmx/RunTriageReferrals",
        beforeSend: function() {
            $("#dialog-modal").dialog({
                position: [175, 175],
                draggable: false,
                height: 140,
                modal: true
            });
        },
        success: function(response) {
            // whatever
        },
        failure: function(response) {
            // whatever
        },
        complete: function() {
            $("#dialog-modal").dialog('close');
        }
    });
});
被翻牌 2024-12-12 09:09:02

它认为你的意思是“阻塞”,而不是“同步”,在这种情况下 - 不,jQuery 模式对话框不是阻塞的。只有浏览器原生的 alert()confirm()prompt() 对话框可以执行此操作。

您绝对可以处理打开模式对话框的 ajax 调用。


听起来您正试图找出代码不起作用的原因。通过 http://sscce.org" rel="nofollow">SSCCE 怎么样? /jsfiddle.net 或 http://jsbin.com

It think you mean "blocking," not "synchronous," in which case - no, jQuery modal dialogs are not blocking. Only browser-native alert(), confirm(), and prompt() dialogs can do that.

You can absolutely process ajax calls which a modal dialog is open.


It sounds like you're trying to figure out why your code isn't working. How about an SSCCE via http://jsfiddle.net or http://jsbin.com?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文