Huge Delay on second jQuery Ajax Request
I try to do some simple Ajax call with refresh of page content with this code snippet:
$("a.ajaxify-watched").bind("click", function(event) {
$item = $(this);
$.ajax({
url: $(this).attr("href"),
global: false,
type: "GET",
data: ({
callback : "inline"
}),
dataType: "json",
async:false,
success: function(msg){
if (msg.status == 200) {
toggleStatus($item, msg)
}
}
});
return false;
});
This works perfect and for me theres nothing to worry about the code but the speed it gets executed.
The first time everything works really fine: 47ms for the operation. But after that every other Ajax call get a constant delay of 2.6 seconds - everytime. I checked with Firebug and found that it is shown as "Waiting Time".
I can't really say whats happening here. We recently 开发者_Python百科switched from pure Apache2 to Nginx Caching Reverse Proxy with load balancing with Apache as Backend Php Interpreter. We could see a huge performance boost and everything is working really fine. I can't tell when my problem first appeared and if it really has something to with our new server setup.
I just found out today, that there is a problem with jQuery so I just wanted to give as much info as possible.
Thank you and let me know if I should provide additional information.
If Firebug indicates waiting it looks like a server issue.
Is there a way to call the pages directly without ajax? If so try to do that and check if the pages load fast or slow?
Also, check that you do not have any events triggering on ajax that might affect this.
Most servers will only handle a single page load from the same server so multiple page loads is handled in queue, so if you have parallell ajax calls they might have to wait for each other.
精彩评论