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?