2013-07-05 3 views
0

내가 자바 스크립트에 새로운 그리고 난 내 코드에서 잘못 찾을 수없는 ... 내가 xhr2.onload에 문제가 생각 날 :자바 스크립트 - 온로드 이벤트

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를 볼 수없는 기능 (addchannel) ... 내가 다른 사람 "이"또는 뭔가 시도했지만 아무것도 작동하지 않습니다 ...

당신 :

답변

0
function addchannel(channel, program) { 
     $('#channel-list').append("<li><h2>" + channel.name + " " program.response.name + "</h2></li>"); 
}; 

감사 나는 어떤 문제를 볼 수 없습니다 범위,하지만 addchannel func에 더하기 기호가 없습니다. (""+ program.response) ...