Reading data from tables/input fields loaded through AJAX

Reading data from tables/input fields loaded through AJAX

I have a bit of code that includes AJAX. I'm reading data from a database through a PHP script and I have to use several queries for the PHP not to time out. However, the problem is that they cause quite a big load, being sent at once. Not to mention disrupting the loading GIF... So I'd like to queue it. How should I approach it? My initial idea was to create a recursive function, solely for the purpose of making an AJAX request. I would store the data in an outside array, along with a counter. Upon finish, AJAX query function would increment the counter and execute itself with the next set of data from the array if it hasn't reached the array's length, and if it did - hid the loading GIF. It didn't seem to work out, though.
Queuing works fine. I wrote the function to execute AJAX query from scratch instead of moving part of the code and it's fine.


There yet another problem. I need to read the data from a loaded table (AJAX loads a table). I placed hidden input fields in cells and I try to read them when AJAX is finished so that the chart can be generated... but no data seems to be read. Does anyone know what I'm doing wrong?