// Fill table with data
function
addRows() {
var
rowsResult =
'' ;
//alert('ssss') ;
$.
getJSON(
'/users/studentlist',
function (
data,
textStatus,
jqXHR){
var
x =
0 ;
$.
each(
data ,
function(){
rowsResult +=
'<tr>'+
'<td>'+
this.
age +
'</td>' +
'<td>'+
this.
fullname +
'</td>' +
'</td>' +
'<td>' +
this.
age +
'</td>' +
'<td><a href="#" class="linkshowstudent" rel="' +
this.
fullname +
'" title="Show Details">' +
this.
fullname +
'</a></td>'
+
'</tr>';
});
//$("table#studentlist").append(rowsResult);
// Inject the whole content string into our existing HTML table
$(
'table#studentlist').
append(
rowsResult);
});
}
now this for handling student details:
// Student Name link click
$(
'a.linkshowstudent').
on(
'click',
function(
event){
event.
preventDefault();
// Retrieve username from link rel attribute
var
thisStudentName =
$(
this).
attr(
'rel');
alert(
thisStudentName) ;
});
any here