【问题标题】:Loading file on JQuery dialog open在 JQuery 对话框上加载文件打开
【发布时间】:2018-03-29 00:47:32
【问题描述】:

我有一个 JQuery 对话框,在里面我正在加载部分视图

       $("#WOdialog").dialog({
                    width: 765,
                    resizable: false,
                    closeOnEscape: true,
                    modal: true,
        close: function () {

        },
        open: function () {
              $(this).load("@Url.Action("AddWorkOrder")");
        }
      });

该部分视图是常规的 html 文件,但它包含一些 <script></script> 标记。这里的问题是我的网站在本地运行,但在部署时却没有。我怀疑这个错误

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.

我知道这与 async 关键字和加载外部 JS 文件有关。 Searched SO 没有任何解决方案对我有帮助。

【问题讨论】:

    标签: javascript asp.net ajax jquery-ui-dialog jqxhr


    【解决方案1】:
    $("#WOdialog").dialog({
                width: 765,
                resizable: false,
                closeOnEscape: true,
                modal: true,
    close: function () {
    
        },
    open: function () {
          //$(this).load("@Url.Action("AddWorkOrder")");
          //Try this
          var $self = $(this);
          var url  = '@Url.Action("AddWorkOrder")';
          $.ajax({
                url: url,
                cache: false,
                async: true
            })
            .done(function( html ) {
                $self.append( html );
            });
        }
    });
    

    【讨论】:

    • 刚试了,还是报同样的错误;(也试过加载不同的局部视图,以为有错误,但什么也没有
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-11
    相关资源
    最近更新 更多