I am looping through a json array and append some of its value to a a div. Looping through works fine. But when i have multiple value in the json. It appends only the last value.
Here is my json
{"msg":[{"id":22,"created_at":"2017-01-16 08:57:43","updated_at":"2017-01-16 08:57:43","profile_name":"VFX DESIGNER","experience":"0-2","skill":"s:10:\"MYSQL,JAVA\";","user_id":"2","comments":"sadsads","aptitude":"yes"},
{"id":23,"created_at":"2017-01-16 08:57:43","updated_at":"2017-01-16 08:57:43","profile_name":"MAYA ","experience":"0-2","skill":"s:10:\"MYSQL,JAVA\";","user_id":"2","comments":"sadsads","aptitude":"yes"}]}
When i loop through to get the profile name , it shows only MAYA in the 2nd value. and VFX DESIGNER is not appended.
$.each(data,function(key,value){
$.each(value,function(index,titleObj){
$("#profiles_name ul").empty();
$("#profiles_name ul").append("<a href = javascript:getCandidates(this) data-value = "+titleObj.user_id+"/"+titleObj.id+"><li>"+titleObj.profile_name+"</li></a><li class = divider></li>");
});
});
.empty()outside of the loop