I am creating a list that shows all the files in the server. The problem is that by each time that I push the “View Files” button that calls this function, it appends files to the list and shows duplicates. For example if I have 2 files on the server it shows 4 files. (first time shows 2 files that is correct but with each times I push button it duplicate).
function MyCallback(data) {
var imagelist = data.imagelist;
var jtext = "<table class='JsonGrid'><tr><th>ID</th><th>NAME</th></tr>";
for (var i = 0; i < imagelist.length; i++) {
var id = imagelist[i].ID;
var name = imagelist[i].name;
var server_path = imagelist[i].server_path;
jtext = jtext + "<tr><td>" + id ;
jtext = jtext + "<td><a href=" + server_path + ">" + name + "</a></td>";
jtext = jtext + "</tr>";
$('#downlodedImage').append('<li>' + '<a href=' + server_path + '>' + name + '</a>');
}
jtext = jtext + "</table>";
$("#jsontext").html(jtext);