简体   繁体   English

jQuery Ajax成功非常缓慢

[英]jQuery Ajax on success is VERY slow

I have a list with 1000 test items, each Item contains 8 propetys. 我有一个包含1000个测试项目的列表,每个项目包含8个属性。 I have a problem with loading time. 我在加载时间上有问题。

When i load the page i run GetListOfTestItems(). 当我加载页面时,我运行GetListOfTestItems()。 The time it takes before it hit return in getTestItems() is under 0.56 seconds. 到达getTestItems()中的return之前所花费的时间少于0.56秒。 Loading time of whole page is 10.78 seconds. 整个页面的加载时间为10.78秒。 Tested in different browsers with same result After ajax hit success it loads right away, so i think extra 10 secnds comes from, when server send result back to ajax. 在不同的浏览器中进行测试,结果相同。ajax成功运行后,它将立即加载,因此我认为,当服务器将结果发送回ajax时,额外的10秒来自。 How to imporove loading time? 如何改善载入时间?

    [WebMethod]
    public static List<TestItem> getTestItems()
    {
        List<TestItem> list = service.getTestItems();

        return list;
    }




function GetListOfTestItems() {
    $.ajax({
        type: "POST",
        url: 'UserProfile.aspx/getTestItems',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: OnAjaxError,
        success: addAnsweredQuestions

    });

}

}

How long does it take until the addAnsweredQuestions is first called? 第一次调用addAnsweredQuestions需要多长时间? it could be the ajax call is a red herring and something else on the page is slowing things down. 可能是ajax调用是红色鲱鱼,而页面上的其他内容正在减慢速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM