Ajax 如果我向Web服务器发出请求,则不会第二次调用Web服务
我使用phonegap 1.5.0和jquery mobile 1.1.0制作了一个应用程序。。。。 我有一个这样的结构Ajax 如果我向Web服务器发出请求,则不会第二次调用Web服务,ajax,web-services,jquery-mobile,cordova,Ajax,Web Services,Jquery Mobile,Cordova,我使用phonegap 1.5.0和jquery mobile 1.1.0制作了一个应用程序。。。。 我有一个这样的结构 <div data-role="page" id="page1"> </div> <div data-role="page" id="page2"> </div> $("#page2").on("pageshow", function(e) { $ .ajax({ type
<div data-role="page" id="page1">
</div>
<div data-role="page" id="page2">
</div>
$("#page2").on("pageshow", function(e) {
$
.ajax({
type : 'GET',
url : "http://192.168.1.88:9051/some.xml"
+ "?time=" + Date.now(),
data : {
key : "value"
},
dataType : "xml",
success : function(xml) {
},
error : function(xhr) {
alert("Error while loading the Mock Service !!!");
}
});
});
如果我第一次进入第2页,这可以正常工作。假设我导航回第1页,然后再导航到第2页,则不会调用Web服务
我甚至尝试了pageinit,但它不起作用。。。这是Ajax的问题吗
如何纠正此问题?您是否尝试过关闭缓存
// setup globally
$.ajaxSetup ({
cache: false
});
或者
您是否使用firebug、“控制台”和“网络”选项卡查看脚本发送和接收的内容
$("#div")
在我看来是不对的。应该是
div
(所有div元素)或#page1
(id'page1')请求使用pagebeforeshow。您可以在$(function(){})中的任何位置声明它;它不工作了。。。有没有一种方法,我们可以删除网页,如果我们隐藏它?你可以张贴你的完整代码?有点不对劲嗨Dennis。。。似乎我只能在整个文档中调用3个Webservice Ajax。。。我在很多场景中测试过它。。。原因可能是什么?您是否已经知道这是web服务还是客户端AJAX问题?
$("#div")