2012-08-14 3 views
0

새 페이지가 나타나면 스크립트를 실행하고 싶습니다. 이렇게 : 을 index.html을에 (링크) : games.html에링크로 전달한 후 스크립트 실행 (jquery mobile)

<a href="games.html" data-transition="slide"><img src="./images/1.jpg" alt="" width='100'/></a> 

하지만이 코드 dont'd 실행 :

$(document).ready(function(){ 
      update_list_games(); 
     }); 

과 기능 :

function update_list_games(gamer_id) 
{ 
      requestToServer(prefix_server + 'load_games_list.php?gamer_id=' + gamer_id, function(response){ 
       if (response.data != null) 
       { 
        if (games_list == "") 
        { 
         for (i = 0; i < response.data.length; ++i) 
         { 
          games_list += "<li class='my_li' onClick=get_game("+i+")><a href='#page3'><img align='left' src='images/"+response.data[i].icon+"' height='45' width='45' style='padding:10px;'/><h3>"+response.data[i].name+"</h3><p>"+response.data[i].description+"</p></li>"; 
         } 
         $("#games_list").append(games_list); 
         $('#games_list').listview('refresh'); 
         $('#games_list').addClass('my_li'); 
        } 
       } 
       else 
       { 
        alert(MES_ERR_SERVER_ACCESS); 
       } 
    }); 

} 

어떻게해야합니까?

답변

0

함수가 매개 변수 (gamer_id)를 필요로하지만 함수없이 매개 변수를 호출합니다. 또한 다른 변수 (예 : prefix_server)와 함수 (requestToServer)라는 함수가 다른 범위 (전역 적으로)로 선언 된 것처럼 보이기 때문에 더 잘 대답 할 수 없다는 것을 알지 못합니다.

+0

function update_list_games - 작동! games.html을 열면 함수가 실행되고 현재 게임을 반환하지만 링크를 사용하면 함수가 호출되지 않습니다. – Alex