Hi,
Have you considered loading all of your data in one hit? It's pretty expensive in terms of network traffic to make a request for each slip.
If your do_payslips_ajax.php script returned a JSON array of all pay slips for a particular year you could then loop the results and build the view from that.
For example, do_payslips_ajax.php returns:
Code:
{
slips: [
{text: "slip text 1"},
{text: "slip text 2"},
{text: "slip text 3"},
{text: "slip text 4"},
{text: "slip text 5"}
]
}
Then if your processing code something like:
Code:
var data = JSON.parse( http_request.responseText );
for(var i=0; i<data.slips.length; i++){
document.getElementById("p" + i).innerHTML = data.slips[i].text;
}
You may also want to look at using a library like jQuery which will give you much more robust code and better cross browser support.