我是 Javascript 新手,我找不到我的代码有什么问题......希望你能帮助我:)
function addchannel(channel, program) {
$('#channel-list').append("<li><h2>" + channel.name + " " program.response.name + "</h2></li>");
};
var xhr = new XMLHttpRequest({ mozSystem: true });
xhr.open("GET", "...");
xhr.responseType="json";
xhr.send();
xhr.onload = function(){
var channels = xhr.response;
for (var i=0; i<channels.length; i++) {
xhr2 = new XMLHttpRequest({ mozSystem: true });
xhr2.open("GET", "..."+channels[i]+"...");
xhr2.responseType="json";
xhr2.send();
xhr2.onload = addchannel(channels[i], xhr2); //HERE IS THE PROBLEM...
}
}
我想我的 xhr2.onload 函数(addchannel)有问题,看不到 xhr2...我尝试使用“this”或其他东西,但没有任何效果...
谢谢 :)