防止UI因ajax调用而冻结

时间:2012-06-04 20:42:12

标签: jquery ajax

第192,193,196,197,199和205行https://github.com/DjangoCoder/DjangoGUI/blob/master/templates/base.html处注释掉的代码冻结了UI。我几乎无法使用我的文本编辑器。我想取消注释这些线。有没有办法在不冻结UI的情况下这样做?该网站位于

http://198.144.178.112:8000

1 个答案:

答案 0 :(得分:4)

您需要将async设置为true。 async参数的目的是允许在浏览器继续使用其余代码时在后台进行此操作。

编辑:对不起,这里有更多信息。

从第173行开始,您应该将ajax函数初始化中的async参数更改为true。像这样:

function testConnection() {
    $.ajax({
        url: "/",
        cache: false,
        async : true,
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            $('#errorbar').css({'height': ($('#header').height()) + 'px'}).show();
        },
        success: function(html){
            $('#errorbar').hide();
        }
    });
}
相关问题