jQuery Mobile的+ PhoneGap的Andr​​oid上 - 没有阿贾克斯 [英] jQuery Mobile + Phonegap on Android - no Ajax

查看:156
本文介绍了jQuery Mobile的+ PhoneGap的Andr​​oid上 - 没有阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:解决方案jQuery Mobile的PhoneGap的+ AJAX的问题:

Solution for JQuery Mobile + Phonegap AJAX Problems:

的子域=真正的 config.xml中属性的不工作在PhoneGap的2.9.0 ,每个请求的子域将返回200但是$就不会触发成功函数($ .getJSON不会闪光反正)。 另外:语法 * domain.tld 在官方的文档说明是不可以的工作,只有这样,我发现来解决这个问题:设置访问的起源和存取权限的URI *(全部)

subdomains="true" property in config.xml is not working in phonegap 2.9.0, every request to a subdomain will return 200 but $.ajax won't fire the success function (and $.getJSON won't fire anyways). Also: Syntax *.domain.tld as stated in the official doc is not working, only way I found to solve that problem: Setting access origin and acces uri to "*" (all)

<access origin="*"/>
<access uri="*"/>


我正在使用jQuery Mobile框架和PhoneGap的移动应用程序。 我只是增加了一个Ajax请求我的应用程序,它被用于从我的网络服务器获取数据。 该页面正确加载而Android(4.1.2)永远不会触发了AJAX事件或永远不会从Web服务器的请求,其实它只是挂在装载微调。


I'm working on a mobile application using the jQuery Mobile Framework and Phonegap. I've just added an AJAX request to my application which is used to get data from my webserver. The page is correctly loading but Android (4.1.2) never fires the AJAX event or never gets a request from the Webserver, in fact it's just hanging on the loading spinner.

关于这个奇怪的是,我已经使用了AJAX请求到同一服务器(但具有不同的域)的作品完美的罚款:

Strange thing about this is, that I already use an AJAX request to the same server (but with different domain) that works perfectly fine:

$.getJSON("[...]checkupdate.php?callback=?", function(data){    
   [...]    
})

我试着做$ .getJSON第二次请求也和它的工作在我的电脑上,但未能在Android上。我开始四处寻找一个解决方案,并发现,高速缓存设置为false $就可以帮助让我改写了我的code,但它仍然没有工作。

I've tried to do the second request with $.getJSON too and it worked on my computer but failed on Android. I started looking around for a solution and found out, that setting the cache to false in $.ajax might help so I rewrote my code but it's still not working.

$.ajax({
cache : false,
type: 'GET',
url: requestURL,
dataType: 'jsonp',
context: document.body,
success: function(data){
    [...]
}});

还有什么做的就是这个工作?

Is there anything else to do to get this to work?

推荐答案

我找到了一种方法来解决这个问题。我注意到,该的子域=真正的属性的PhoneGap的config.xml无法正常工作。 (PhoneGap的2.9.0)。每一个请求到子域名将返回状态200,但 $。阿贾克斯将不发射成功,函数( $。的getJSON 将不会触发反正)。语法 *。domain.tld 作为官方文档说是不是为我工作要么,只有这样,我发现解决这个问题设置访问来源和存取权限的URI *(全部)

I found a way to solve that problem. I noticed, that the subdomains="true" property in phonegap's config.xml is not working. (Phonegap 2.9.0). Every request to a subdomain will return status 200 but $.ajax won't fire the success function (and $.getJSON won't fire anyways). The syntax *.domain.tld as stated in the official doc isn't working for me either, only way I found to solve that problem was setting access origin and acces uri to "*" (all)

这篇关于jQuery Mobile的+ PhoneGap的Andr​​oid上 - 没有阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆