I have a set of jSon data (no errors) that I need to execute using the $ .each function, but it only displays the last data record from jSon.
This is jquery for:
$.ajax({ type: "POST", url: '/update-recent-stat', dataType: 'json', success: function(jsonData) { var counterjson = 1; $.each(jsonData, function(i, value){ var count = counterjson++; var link = jsonData[count].linkid; var time = jsonData[count].time; var value = jsonData[count].value; var sender = jsonData[count].sender; $("#DownBoxL ul li").html("<div class=Timestamp>"+time+"</div><div class=UserName><a href=\"#"+link+"\">"+sender+"</a> ("+count+") msg sent!</div><div class=TagValue>+"+value+"</div>").show(); }); } });
Thus, jSon data is a set of 15 records, for example:
[{"counter":"1","linkid":"1448524027","sender":"User1","value":"5","time":"5 sec ago"},{"counter":"2","linkid":"1448524027","sender":"User2","value":"5","time":"5 min ago"}]
For a record with this part of the code, only the last record is displayed!
Does anyone know where the problem is?
Thanks Hi.
source share