当移动应用程序页面加载时调用Javascript函数
我有一个移动应用程序,它有多个页面。在其中一个页面上,我有一些javascript向php页面发送请求以获取一些数据 现在数据完全返回了,但是它会在主索引页加载并立即显示数据后立即加载。我试图做的只是在打开main index.html页面中的特定页面时显示信息 下面是立即加载数据的代码当移动应用程序页面加载时调用Javascript函数,javascript,Javascript,我有一个移动应用程序,它有多个页面。在其中一个页面上,我有一些javascript向php页面发送请求以获取一些数据 现在数据完全返回了,但是它会在主索引页加载并立即显示数据后立即加载。我试图做的只是在打开main index.html页面中的特定页面时显示信息 下面是立即加载数据的代码 $(document).ready(function(){ $.ajax({ //create an ajax request to load_page.php type: "GET",
$(document).ready(function(){
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "http://domain/group_list.php",
dataType: "html", //expect html to be returned
success: function(response){
$("#responsecontainer").html(response);
//alert(response);
}
});
});
我试着把它改成这个,但当我这样做的时候,信息根本没有显示出来
$(document).on('pageinit', '#three', function(){
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "http://domain/group_list.php",
dataType: "html", //expect html to be returned
success: function(response){
$("#responsecontainer").html(response);
//alert(response);
}
});
});
因此,我添加的代码已经过时,应该是下面显示的代码,一旦我做了这些更改,它就可以完美地工作了
$(document).on("pagecreate","#three",function(event){
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "http://domain/group_list.php",
dataType: "html", //expect html to be returned
success: function(response){
$("#responsecontainer").html(response);
//alert(response);
}
});
});