local-host 2017-07-13 09:36 采纳率: 100%
浏览 53

jQuery ajax等待时间长

I'm using jQuery ajax to call a webmethod in my asp.net page, here's the code:

$.ajax({
            type: 'POST',
            url: 'Home.aspx/GetPlantInfo',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (response) {
                info= JSON.parse(response.d);
                $("#PlantName").val(info.Name);
                .
                .
                .
            },
            failure: function (r) {
                alert(r.d);
            }
        });

the webmethod does a simple linq query and serializes the result to a JSON string, which takes less than half a sec. here's the webmethod code:

        [WebMethod]
    public static string GetPlantInfo()
    {
        MyDataClassesDataContext dc = new  MyDataClassesDataContext();
        Plant p = (from x in dc.Plants
                       where x.Name == "someName"
                       select x).FirstOrDefault();
        string plantJson = JsonConvert.SerializeObject(p);
        return plantJson;
    }

however the ajax call takes 10-15 seconds to complete. I inspected ajax timing and apparently most of this time is "Waiting" time, with negligible send and receive time. I googled this problem with no lock. What I'm asking is what exactly is this "Waiting" time? Is the problem from IIS server? is something wrong with my code?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号