Using PHP, I would like to make a while loop that reads a large file and sends the current line number when requested. Using Ajax, I\'d like to get the cur
You're confused as to how PHP and AJAX interact.
When you request the PHP page via AJAX, you force the PHP script to begin execution. Although you might be using flush() to clear any internal PHP buffers, the AJAX call won't terminate (i.e., the response handlers won't be called) until the connection is closed, which occurs when the entire file has been read.
To accomplish what you're looking for, I believe you'd need a parallel process flow like this:
You could accomplish this inter-process communication through $_SESSION variables, or by storing data into a database. Either way, you need a parallel implementation instead of your current sequential one, otherwise you will continue to get the entire status at once.