【问题标题】:Ajax requests in phonegap projects on androidandroid上phonegap项目中的Ajax请求
【发布时间】:2013-09-01 08:23:22
【问题描述】:

我的基于 dojo 的项目在 phonegap 2.7.0 上运行良好,但在使用 phonegap 3.0“升级”后,似乎没有一个 ajax 请求通过。

我用纯 javascript 创建了一个简单的测试页面(以消除 dojo 作为变量),结果是相同的。

谢谢 迈克

我的环境

  1. phonegap 3.0
  2. Galaxy S3 上的 Android 4.1.1,或模拟器上的 Android 4.3
  3. 存在于清单中
  4. 存在于 config.xml 中

javascript:

    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange=function(){
      alert ("rdystate: " + xmlhttp.readyState);
      alert ("status: "   + xmlhttp.status);
      alert ("Text: "     + xmlhttp.statusText);
      alert ("ResponseText: " + xmlhttp.responseText);
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {
        alert(xmlhttp.responseText);
      }
    }
    xmlhttp.open("GET","http://10.0.2.2:8080/myapp/rest/feedback/ping",true);
    xmlhttp.send();

输出:

    rdystate: 1
    rdystate: 2
    status: 404
    Text: *empty*
    ResponseText: *empty*
    rdystate: 4
    status: 404
    Text: *empty*
    ResponseText: *empty*

【问题讨论】:

    标签: javascript android ajax dojo cordova


    【解决方案1】:

    我对此不是 100% 确定,但我相信使用 IP 地址可能属于域白名单?您可以将 DNS 记录指向它并尝试改用域名吗?

    【讨论】:

      猜你喜欢
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 2011-11-15
      • 1970-01-01
      相关资源
      最近更新 更多