传递给链接后运行脚本(jquery mobile)

时间:2012-08-14 13:39:33

标签: jquery mobile load

我想在新页面出现后运行脚本。 这样做: 在index.html(链接):

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

,但此代码不会运行:

$(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);
                }
    });

}

我该怎么做?

1 个答案:

答案 0 :(得分:0)

你的函数需要一个参数(gamer_id),但你没有参数。还有其他变量(f.e.prefix_server)和函数中调用的函数(requestToServer)似乎在不同的范围内声明(全局?),所以不知道它们我不能更好地回答。