より多くのヘルプ、別の問題。内側のループからallLessonsArrayを返したいのですが、何らかの理由でループ関数の外側に到達しません。どこで機能し、どこで機能しないかを説明しました。これを外部に戻すにはどうすればよいですか?
var allLessonsArray= new Array();
$.each(lessonInTopicSectionArray, function(index, lesson){
var lastAttempt = 0;
url='domain/learn/mod/lesson/report.php?id='+lesson.id+'&action=reportdetail&userid='+userid+'&try='+lastAttempt;
$.get(url, function(data) {
var lessonArray= new Array();
$(data).find('tr.r1.lastrow td.cell.c0')
.each(function(index, content) {
var string=jQuery(content).html()
score=parseInt(string.substr(string.length - 1));
lessonArray[index]=score;
});
allLessonsArray[index]={name:lesson.name, score: lessonArray};
//This works.
alert(allLessonsArray[0].name);
alert(allLessonsArray[0].score[0]);
});
//This doesn't work.
alert(allLessonsArray[0].name);
alert(allLessonsArray[0].score[0]);
});
return allLessonsArray;