This is the third time I’ve tried getting help with this on stackoverflow.
Basically what I am trying to do is get a url page, then grab content from each element ‘tr.r1.lastrow td.cell.c0’.
Everything about the code is working except the innermost .each loop. I believe I have just wrote the each function wrong. What am I doing wrong here?
Edit: this has been solved san substr, which is just an error. Thanks all.
var allLessonsArray= new Array();
$.each(lessonInTopicSectionArray, function(index, lesson){
var lastAttempt = 0;
url='------/learn/mod/lesson/report.php?id='+lesson.id+'&action=reportdetail&userid='+userid+'&try='+lastAttempt;
$.get(url, function(data) {
var lessonArray= new Array();
$('tr.r1.lastrow td.cell.c0').html(data).each(function(index, content) {
alert(jQuery(content).html());
score=parseInt(content.substr(content.length - 1));
lessonArray[index]=score;
});
allLessonsArray[index]={name:lesson.name, score: lessonArray};
});
});
The problem is in this part:
you are actually selecting cells and replacing them with retrieved data. What you meant was probably this:
which will execute “
tr.r1.lastrow td.cell.c0” selector on retrieved documents.