I'm struggling with a weird yet randomly reproducable constant problem in our 
systems jQuery AJAX-responses.

Some of our pages have links that trigger the loading of content in a large div 
in the page. Rather basic fetching of HTML with jQuery. The problem is that 
randomly, approximately once out of ten requests, the response from the server 
is cut short. Only about half of the HTML seems to arrive and is put into the 
div. Obviously this messes things up.

First thing I did, obviously was to take a deep look at the php script 
producing this bit of HTML, to see if there was something wacky. After some 
digging though, It seems that the problem does not lie in the script producing 
the content, but propably somewhere within apache, http-request headers or the 
parsing of the response. I'm asking here because I hope someone here could 
point me to the right direction. Google has'nt really been my friend on this.

The facts (please do check these before replying):

A) The effect is totally random, approximately 1 out of 10 times the response 
is cut short.
B) The response does not get cut from the same spot every time
C) Looking at Firebug, the response is cut short there too, this would lead me 
to assume it's not a problem with my jQuery code, but rather the actualy HTTP 
response really is cut short.
D) Opening the page that is loaded with ajax in a normal browser window and 
refreshing it never produces the error. The error only happens when this same 
URL is loaded with AJAX. This stronly makes me believe the error does not lie 
within the underlying php script or page, which is really basic).
E) The error happens at least on 2 completely different pages dynamically 
loading two different urls on the same server. (This also would point away from 
a php error)
F) Have tried the exact same code on another identical server with identical 
results
G) So far I've only managed to reproduce the problem when I'm browsing through 
an SSH-tunnel. using an identical server in LAN without SSH in between seems to 
work fine. This is not conclusive however, I've not had a chance to test the 
exact same server with bot offsite ssh-tunneling and onsite lan without ssh.

I'm strongly suspecting some Apache setting to be causing this. The response 
headers indicate "Transfer-Encoding: chunked", but I couldn't find anyone else 
having a problem with it and AJAX. Plus the fact that most pages work fine, and 
even the problematic ones totally randomly fail.

Any ideas really appreciated. Debugging this has proven to be extremely 
difficult.

I'm sorry I cant product a live example at this moment. It might prove to be 
rather difficult, and might actually be a bit irrelevant since I really don't 
think the code is to blame here.

What could either cause the server to send clipped responses, or to make the 
browser evaluate the response as complete when in fact it might not yet be?

-- 
Suni

Reply via email to