2011-07-24, 05:24 PM
I'm in the process of writing some javascript pagination for a site that I'm working on. The idea of it is that once you get to the bottom, you click on "load more" and the additional content is loaded via AJAX and appended to the table displaying it.
Now, I have the PHP side of things working fine. The output is being collected properly and I can print it out with document.write().
However, I cannot manage to get it placed into the table. Below is the code that I have with previous attempts commented out but kept as a note.
I can provide the HTML if it is required but it is quite a big table so I thought it would be better to just see if I'm being stupid with the javascript.
Now, I have the PHP side of things working fine. The output is being collected properly and I can print it out with document.write().
However, I cannot manage to get it placed into the table. Below is the code that I have with previous attempts commented out but kept as a note.
$.get("http://domain.com/updates/more/" + offset, function(data){
//$(data).appendTo("table.posts");
//$("table.posts").append(data);
//$("table.posts tr:last").after(data);
document.write(data);
});
That is inside the callback function for the click.I can provide the HTML if it is required but it is quite a big table so I thought it would be better to just see if I'm being stupid with the javascript.