Received a JSON response as follows:
{
"name" : "chanchal",
"login3" : "1534165718",
"login7" : "1534168971",
"login6" : "1534168506",
"login5" : "1534166215",
"login9" : "1534170027",
"login2" : "1534148039",
"lastname" : "khandelwal",
"login4" : "1534166200",
"login10" : "1534147907",
"login8" : "1534169966",
"login1" : "1534147962",
"id" : "1",
"user_id" : "1002"
}
The code for the Script function is provided below:
function showHistory(usrId)
{
$.ajax({
type: "POST",
url: loc+"AdminController/loginHistory",
data: { usrId : usrId },
success : function(data)
{
var obj = JSON.parse(data);
var output="";
console.log(data);
output += '<div class="tabs">';
output += '<ul class="tab-links"><li class="active"><a href="#name">'+obj.name+' '+obj.lastname+'</a></li></ul>';
output += '<div class="tab-content">';
output += '<table class="flat-table"><tbody><tr><th>No.</th><th>Login Time</th></tr>';
for(var j = 1 ; j<= 10 ; j++)
{
output += '<tr>';
output += '<td>'+j+'</td>';
output += '<td>'+obj.login+j+'</td>';
output += '</tr>';
}
output += '</tbody></table>';
output += '</div></div>';
$('#result_tbl').html(output);
}
});
}
Desired to display login times in a table by concatenating login with numbers from 1 to 10. Any suggestions on how to achieve this efficiently?