i want to append unlimited number of HTML elements with data given as comment. This is my ajax:
function ajaxsubmit(){
$.ajax({
url: "/update",
type: "POST",
dataType: "html"
}).success(function(data) {
$('#result').html(data);
});
}
and my HTML part:
<div class="post" id="result"></div>
this is my serverside function:
public static Result ajaxupdate(){
String done = "test";
return ok(done).as("text/html");
}
This function is appending only once, and if I click for the 2nd time, it is not appending. Is it because I should have different ID’s each time? How is that possible (like in stackoverflow how several comments work!)
Thanks, in advance..
When you use
$('#result').html(data);the content of#resultis replaced with the new data.To append the new data to
result, use