Skip to content Skip to sidebar Skip to footer

.ajax() Call Won't Complete Until Previous .ajax() Call Is Complete?

So, i'm working on a progress bar for a CSV processing script. dnc_scrubber.php goes through the CSV and checks a phone number against a database, returning matched and unmatched

Solution 1:

Most likely, your server limits the number of concurrent connections per user to 1. Or, you are using sessions and the first script has it locked. The second script will be blocked until the first one releases its lock on the session file. Only use session_start() if you need to, and release the lock with session_write_close() as soon as you are done with it.

Edit: I'm not sure if this will work, but you could try it. Each time you want to update the session, call session_start(), update the session, then call session_write_close(). I'm not sure if you are allowed to do that multiple times in a script, but it seems like it should work.

Solution 2:

Not sure if this is the exact cause of your problem, but it is something that needs fixed.

Change

setTimeout(doProgressBar(), 100);

To

setTimeout(doProgressBar, 100);

You are calling doProgressBar immediately, not after the timeout is complete.

Solution 3:

Ajax would be assync.

lines.php is probably waiting on dnc_scrubber.php as the first one has locked MySQL.

This is just guessing as we don't have your PHP code but try to run both PHP scripts manually and check if lines.php doesn't wait for MySQL to finish.

Solution 4:

when reading your .csv file with your PHP code is it locking the file? so if it has to read it twice, it will only read it when the previous code closes the stream?

what happens if you open 2 browsers and run the code at the same time? do both browsers execute at the same time with the same results? or is there a wait on the file?

Post a Comment for ".ajax() Call Won't Complete Until Previous .ajax() Call Is Complete?"