Wes Dollar
Wes Dollar

Reputation: 367

AJAX console.log with each PHP Iteration

I am using ajax to call a php script that is looping through a rather long data set. I would like to log the iteration ($i) to the console with each pass.

Is there a jQuery method that can "listen" while the script is running and log each pass to the console?

Sorry for not posting an example... I'm a little pressed for time.

Upvotes: 0

Views: 304

Answers (1)

MWJump
MWJump

Reputation: 91

Since the php script wont return stuff through the server (and therefore through ajax) until it is done executing or you flush the output buffer (which would mean you couldn't send anything else later), you need to log its iterations somewhere, a file, session (this is tricky since they can't access it concurrently), the database or something like Memcache and then read that from a second script you would poll with ajax.

Polling isn't exactly listening like you mentioned in your question though. If polling isn't good enough you will need to look into setting up something like COMET, but its likely with a short enough polling interval, for this purpose, it would be acceptable.

Upvotes: 1

Related Questions