I have a jquery function loading a php file which will output some data into a div.
The code:
function add(){
$("#div").load("add.php");
}
Now the problem is, I need to be able to use the function several times without my content in #div being overwritten. So now each time I use the function the text inside the div is deleted and the new content is inserted.
How could I fix this problem?
Try this:
where
divis a reference to your DIV element. (You want to have a reference of course, instead of querying for the DIV on each invokation ofadd().)Update:
So, the data returned from the server is a
'<li>...</li>'string, which means that you want to append it directly to the UL element: