Is there a more efficient way to generate HTML for the JSON returned array of users? Please review the following code and advise if I should use templated code or follow a standard approach for this scenario:
success: function(e){
console.log(e);
console.log(e.d[0].UserName);
var position2 = $("#searchtextbox").position();
$('<div/>', {
id: 'generatedsearchdiv',
css: {
position: 'absolute',
left: position2.left,
top: position2.top + 20
}
}).appendTo('#searchArea');
for (var i = 0; i <= e.d.length; i++) {
$('<div/>', {
html: "<span>"+e.d[i].UserName+"</span>"
}).appendTo('#generatedsearchdiv');
}
}