View Full Version : why the ajax request to php blocks

29 Dec 2009, 12:37 AM
two Ext.Ajax.request to some php,
the first: query database, costs 50 second
second: costs 2 second

send the first ajax -> then send the second ajax -> in firebug, i can see the second php is blocked -> after the first php returns -> then the second php start to excute and then return.

is there anyway to let the php can handle 2 ajax request at the same time ?

i'm using winXP + apache + php.


29 Dec 2009, 12:54 AM
which browser are you using? This is not an issue of the serverside component (php, asp,jsp) but a limitation of the browser defaults: Using a maximum of 2 http-requests from the same domain. So, if your first ajax request runs and some other css/js/jpg/gif is still loading, the browser waits for some free "slot" to start the next request

29 Dec 2009, 1:37 AM
I'm using FireFox 3.5.6(with firebug installed) .
here is the screenshot,
the second ajax never returns until the first ajax returns, and there is no other jpg/gif..etc to load

29 Dec 2009, 2:52 AM
:-?mmh, are you sure, your PHP Code is correct and doesn't loop? if the server side code hangs within some loop firebug will show a similiar screen (but should cancel the request in 30 seconds by default (which php also does by default if not "
set_time_limit(0)" has been set)

29 Dec 2009, 7:20 AM
there is no dead loop, the first php queries data from database, so it takes long time(about 60 sec), the second request should return in 3 sec, but it always wait for the first to return, then it start to excute.

29 Dec 2009, 8:30 AM
as seen on the screenshot you are calling the same php-script. Do you also call the same javascript subroutine to call the ajax-request twice? i would try to call a different script (just copy the php file to another name for testing or just a simple php script which does some logging just to see when its been called)

i also think to remember you can change the amount of simultanious ajax-requests per domain somewhere in the registry (or about:config)...

29 Dec 2009, 8:35 AM
mmh, if you are calling the same php script, which loads data from a database and need 60 seconds on first time, i think it is still loading the second ajax-request, but this one also needs 60 seconds but has been started later. So for you, it looks like the second request starts when the first has been finished. i don't think this is the case here (do some error_logging in you interface.php to see if the second time the request started, the first one is still running)

Mike Robinson
29 Dec 2009, 8:46 AM
Ideally, you would refer to the server-side logs as well as Firebug; in other words, correlate the two against one another. But then again, the server-side logs alone might be sufficient. You need to know exactly when each request was received by the host, and when each of them was started.

From there, it's going to be a fairly simple question of configuration changes.

My gut-feeling here is that it's going to be a client-side setting.

29 Dec 2009, 9:25 AM
i'm querying the same 'interface.php', that's the point I didn't considered. though the 'interface.php' does different things for the two ajax requests. I changed the second request url to 'xxx.php', and the problem seems to be solved, the second request returns before the first one..
Many Thanks for your reply, wm003 and Mike.