I have a situation, where some records will be searched from a database, and then is the process button is clicked, an ajax process will initiate that will process the first row, when the first row is done, then it will automatically initiate the ajax process for row 2 and so on.

I want to know what is the best way to do this ?

What i have in my mind is that, passing all the rows id in via ajax to the script and then script process and return the next id, and on the reply, if there is an id, then another ajax will initiate the process with this id, and then so on.

For example,

here are the ids, 2,3,4,5,7,8,9

i will sent this to the php script like this
PHP Code:
Process.php will process 2, and will also return the next id (3) and all the ids (2|3|4|5|7|8|9) so that on reply, the next ajax will initiate with


and so on,

Is this correct approach ?