AJAX - mass db insert with progress

Associate
Joined
18 Oct 2002
Posts
1,312
Location
Milton Keynes
Heya

Have been trying to get something working for a while now and its not playing ball. I have a mass emailer script, and I want it to show progress of how that campaign is sending once you click send.

Basically want to click go and it will run the script that will loop through and send the emails. Want to also have another query running every 10 seconds or so to see all the emails that have been sent for that batch.

Problem is that when I run both at the same time it wont return the select query until the inserts have finished :( Any ideas?

I believe it might have something to do with sessions and 'race conditions'? Basically want to strip it right back to forgetting the emails I have just an insert query and a select query, as each row goes in i want it to show the latest rows in a progress list. Anyone done this?
 
Can we see your javascript code please

Just asking if the theory is achievable or not. Ie can you have 2 scripts being run by ajax, one being an insert query and one being a select query to show progress

was just thinking if i left a massive insert script going, you can check phpmyadmin to see how its doing even though the php insert script hasnt displayed anything yet. Want something like that but running from the same page.
 
Last edited:
infact it doesnt even have to be 2 scripts, i just want some kind of progress of the inserts

cant find any helpful information anywhere and it just seems like someone somewhere must have wanted to do the same thing??
 
i'm guessing the script is on some sort of loop? if so can you not get it so change a div to the amount of times the script has run, so basically script run, counter++, replace text area with counter, start again, script run, counter++ etc...
 
I would simply do a counter javascript side and have the loop javascript side and just count how many times the page has successfully executed and loaded the innertext of "done" or something along those lines.
 
You could improve that by getting the number of emails to be sent and make a proper progress bar by working out the % complete from that and the number of times the loop has been run.

But yes we would need to know how your code would work and as said I would not recommend concurrent read/write ops on any single database table if it can be avoided.
 
Back
Top Bottom