FORUMS: list search recent posts

AJAX what happens when...

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dan Browne
AJAX what happens when...
on Jun 11, 2009 at 7:25:20 am

Does any body know the answer to this?

If I use AJAX to execute a PHP file.. and the PHP file takes a long time to finish executing (its going through directories indexing files and putting them into a database).. If someone clicks a button and the AJAX executes the PHP file, but then the person navigates away from the page the AJAX request was made.. will the PHP file stop executing even if it hasnt finished processing everything.

I'm trying to make something that will go through and check images under a few directories and link them by name to elements that are in a MYSQL database.. it then puts the links into the database to tell the script where the files are. I was going to make it just a cron job that executes say every week or something.. but have decided I want it to be user controlled so the user can specify when they want to index everything.

Does anyone know?


Dan Browne
Hawkes Bay, New Zealand

Return to posts index

Mike Smith
Re: AJAX what happens when...
on Jun 11, 2009 at 9:05:46 am

Why would the php file stop, unless it received a command to do so?

If you were to want it to stop, wouldn't you have to set up a javascript onUnload event to call a (php or other serverside) script to send an appropriate command ..?

Return to posts index

Curtis Thompson
Re: AJAX what happens when...
on Jun 11, 2009 at 3:17:02 pm


an easy way for you to test this would be to create a simple php script that just created an empty file in a directory - then, use sleep() ( and set it for a few seconds and then write another file - so like 1.txt, 2.txt, etc. - however many and however long you want to run the loop...

then call it via ajax in another page and leave that second page - you answer will come if you see the loop you set up finish and keep writing files even if you aren't on the calling ajax page any longer...


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved