好的,伙计们,我正在尝试在getIndividualMap
函数中使用该变量,但出现undefined
错误。可能是什么问题呢?
var i;
for(i=0;i<=(data.length -1);i++)
{
$('#ResultsId').append("<table border='1'>" +
"<tr>" +
"<th>UserID</th>" +
"<th>RUNDATE</th>" +
"<th>NAME</th>" +
"<th>TIME</th>" +
"<th>DISTANCE (KM)</th>" +
"</tr>" +
"<tr>" +
"<td>" + data[i].UserID + "</td>" + " " +
"<td>" + data[i].runDate + "</td>" + " " +
"<td>" + data[i].firstName + "</td>" + " " +
"<td>" + data[i].Time + "</td>" + " " +
"<td>" + data[i].Distance + "</td>" +
"<td>" +"<a href='#' onclick= 'getIndividualMap(i)'>" + data[i].UserID +"</a>" + "</td>" +
"</tr>" +
"</table>" );
}
getIndividualMap(){
console.log(i);
}