I am making an jQuery Mobile and PhonGap app. It connects to the server-side web-services by AJAX calls using JSONP (I know about cross-domain issues, although my android dev does not suffer it). I am using PhoneGap Build to prepare an application for many operating systems.
我正在制作一个jQuery Mobile和PhonGap应用程序。它通过使用JSONP的AJAX调用连接到服务器端的Web服务(我知道跨域问题,虽然我的android开发人员不会受到影响)。我正在使用PhoneGap Build为许多操作系统准备应用程序。
Here is my problem: I made a index.html that makes an AJAX call to server. I am getting an response and I am redirected to main.html. It works fine on chrome, safari and my Android device.
这是我的问题:我创建了一个对服务器进行AJAX调用的index.html。我收到了回复,我被重定向到main.html。它适用于chrome,safari和我的Android设备。
On the second site: main.html, I have similar request (I also tried with the same request) which doesn't get called on Android device. However it works fine on both Chrome and Safari.
在第二个网站:main.html,我有类似的请求(我也尝试过相同的请求),在Android设备上没有调用。但它在Chrome和Safari上都可以正常使用。
I tried switching off cache, proper permissions are granted, is added to config.xml. Note that I also tried to compile my app by eclipse, and with no result I added to /res/xml/cordova.xml.
我尝试关闭缓存,授予适当的权限,添加到config.xml。请注意,我还尝试通过eclipse编译我的应用程序,但没有结果我添加到/res/xml/cordova.xml。
I checked server logs, there are no requests from the second site. Here is the code:
我检查了服务器日志,没有来自第二个站点的请求。这是代码:
Note: I also read jQuery mobile docs according to PhoneGap. Changing $(document).ready doesn't solve the problem. This construction works on index.html site.
注意:我还根据PhoneGap阅读了jQuery移动文档。更改$(document).ready并不能解决问题。此构造适用于index.html站点。
$( document ).bind( "mobileinit", function(){
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.mobile.loadingMessageTextVisible = true;
$.mobile.showPageLoadingMsg();
console.log('Start Strony');
})
$( document ).ready(function (){ //
$.ajaxSetup ({
cache: false
});
console.log('Start');
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.ajax({
crossDomain: true,
type: 'GET',
url: 'http://ip/services/rest/contact/list',
callback: 'jsonpCallback',
jsonpCallback: 'jsonpCallback',
jsonp: '_jsonp',
scriptCharset: "utf-8",
contentType: 'application/json',
dataType: 'jsonp',
timeout : 5000,
success: function(data){
var html ='';
console.log('Success');
$.each(data.response, function(key, value) {
html += '<li><a class=contact href="#" id="' + data.response[key].id + '" ><h1>' + data.response[key].label + '</h1><p>'+ data.response[key].customerName + '</p><p>' + data.response[key].phone + ', ' + data.response[key].email + '</p></a></li>';
$('#ul_id').append($(html));
html='';
console.log('conatct');
});
$('#ul_id').trigger('create');
$('#ul_id').listview('refresh');
//localStorage.setItem('idCustomerValue', data.re);
},
error: function (xhr, ajaxOptions, thrownError){
alert("Status: " + xhr.status + ", Ajax option: " + ajaxOptions + ", Thrown error: " + thrownError);
//location.reload();
console.log('Blad');
},
});
});
Unfortunately, I cannot provide you server side code. Server is setup properly. As I mentioned Chrome and Safari work.
不幸的是,我无法为您提供服务器端代码。服务器设置正确。正如我提到的Chrome和Safari工作。
1 个解决方案
#1
0
The problem was pageinit event and specific behaviour while linking in JQM.
问题是在JQM中链接时的pageinit事件和特定行为。
#1
0
The problem was pageinit event and specific behaviour while linking in JQM.
问题是在JQM中链接时的pageinit事件和特定行为。