Hi people,
I'm having a very strange old time with a little bit of jQuery/php combo, and I'm not sure where the problem lies. The order of events that takes place is:
1. index.php sends some html to the browser, including some "launch" js
2. this launch code sends an XMLHTTPRequest to a php script, telling it to start scanning a site (this scan takes a long while so this php script doesn't return anything for at least 40 seconds)
3. this scan process starts inserting records into my database, so that then:
3. as the above is done asynchronously, i then, from the same js code, ask the same php script for a different function - a status update of what's gone into the database so far
4. in theory this should respond instantly and i can have a nicely "real time" updating counter back on the original html page
I hope I've explained that well. Essentially I need to scan 100+ pages of a website for certain info (scraping, if you will, although this isn't nefarious) but don't wish to leave the browser sat there for 40+ seconds, so I trigger the php scan script via ajax, then immediately use setTimeout to call a "give me an update" php script.
However this step of asking the php script for an update doesn't return anything at all until the first scanner script has finished, some 40+ seconds down the line. The JS is definitely sending both requests, but the webserver doesn't even invoke the index.php script for the "give me an update" until after the scanner is done.
This sounds like a webserver configuration issue to me, but I'm at a loss. I can access other php scripts on the webserver just fine, but seemingly not this index.php I'm passing all these (well, these two) requests through. Is there some limit in apache with how many concurrent instances of a single script it can have open or something? It's really doing my nut in.
I'm having a very strange old time with a little bit of jQuery/php combo, and I'm not sure where the problem lies. The order of events that takes place is:
1. index.php sends some html to the browser, including some "launch" js
2. this launch code sends an XMLHTTPRequest to a php script, telling it to start scanning a site (this scan takes a long while so this php script doesn't return anything for at least 40 seconds)
3. this scan process starts inserting records into my database, so that then:
3. as the above is done asynchronously, i then, from the same js code, ask the same php script for a different function - a status update of what's gone into the database so far
4. in theory this should respond instantly and i can have a nicely "real time" updating counter back on the original html page
I hope I've explained that well. Essentially I need to scan 100+ pages of a website for certain info (scraping, if you will, although this isn't nefarious) but don't wish to leave the browser sat there for 40+ seconds, so I trigger the php scan script via ajax, then immediately use setTimeout to call a "give me an update" php script.
However this step of asking the php script for an update doesn't return anything at all until the first scanner script has finished, some 40+ seconds down the line. The JS is definitely sending both requests, but the webserver doesn't even invoke the index.php script for the "give me an update" until after the scanner is done.
This sounds like a webserver configuration issue to me, but I'm at a loss. I can access other php scripts on the webserver just fine, but seemingly not this index.php I'm passing all these (well, these two) requests through. Is there some limit in apache with how many concurrent instances of a single script it can have open or something? It's really doing my nut in.