在加载移动应用程序页面时调用Javascript函数
call a Javascript function when a mobile app page loads
我有一个移动应用程序,它有多个页面。在其中一个页面上,我有一些javascript,它向php页面发送请求以获取一些数据。
现在,数据被完美地返回,但是一旦主索引页加载并立即显示数据,它就会加载。我想做的是只在主index.html页面中的特定页面打开时显示信息。
下面是直接加载数据的代码。
$(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);
}
});
});
相关文章:
- 我需要从php调用javascript或jquery
- 如何在webView,Android中从@JavascriptInterface方法调用Javascript
- 使用html表单中的参数调用JavaScript函数
- 可以´t调用JavaScript中的函数
- 在按钮上调用Javascript函数
- 如何从Objective-C代码中调用javascript代码
- 当库在页脚中加载时,基于PHP条件调用Javascript
- 可以't在Jasmine中调用Javascript函数
- 在page_load事件上调用javascript函数
- 如何在ajax中调用javascript对象的方法
- 如何使用WPF调用JavaScript对象的函数
- 我们可以用参数对象集合而不是原始数据来调用JavaScript collection.reduce()方法吗
- 在新的浏览器选项卡上加载新的aspx页面后调用JavaScript函数
- 从附加文本调用javascript(订单车)
- 在线程循环中调用JavaScript
- 在指定时间后多次调用Javascript中的函数
- 未调用Javascript onscroll事件
- 如何正确调用Javascript中的匿名函数
- 从字符串调用javascript函数
- 无法从活动调用 javascript 函数