加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

来自黑莓OS5 phonegap应用程序的Ajax调用失败

发布时间:2020-12-16 02:48:04 所属栏目:百科 来源:网络整理
导读:为什么这个ajax调用不能在我的BB OS5上工作并且在BB OS6中工作 $("#HomePg").on('pageinit',function(event) { $.ajax({ dataType:'json',url: serviceURL+'linka',error: function(xhr,status,error) { alert("Cannot Connect to the Specified URL : "+sta
为什么这个ajax调用不能在我的BB OS5上工作并且在BB OS6中工作

$("#HomePg").on('pageinit',function(event) {
   $.ajax({
        dataType:'json',url: serviceURL+'linka',error: function(xhr,status,error) {
                  alert("Cannot Connect to the Specified URL : "+status);
             },success: function(json) {
                $.each(json,function(i,object) {
            var cr = "<li id='menuList'><a id="+object.id+"  
                   data-transition='slide' class='menuClass' ><img src=css/images
                   /"+object.id+".png /> <h3> "+object.menuname+" </h3></a></li>";
               $("#mainMenu").append(cr);
               $("ul").listview("refresh");
               mainloaded = true;

        });

       },timeout:60000,retryMax: 10
  });

 });

…. config.xml中

<access subdomains="true" uri="*"/>

<rim:connection timeout="60000">
<id>TCP_WIFI</id>
<id>TCP_CELLULAR</id>
<id>BIS-B</id>   
<id>MDS</id>
<id>WAP2</id>
<id>WAP</id>
</rim:connection>

………

我使用jqm 1.1.1版本与jquery 1.7.2
这适用于BB OS6

解决方法

排序:

看起来BB OS5有jQuery-Ajax的问题??..对于尝试使用XMLHttpRequest尝试相同尝试的人.

$("#homePg").on('pageinit',function(event) {   
var url = serviceURL+'testgroups'
http.open("GET",url,true);
http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        //alert(http.responseText);
        var json = JSON.parse(http.responseText);
        $.each(json,object) {
            var cr = "<li id='menuList'><a id="+object.id+"  data-transition='slide' class='menuClass' ><img src=css/images/"+object.id+".png /> <h3> "+object.menuname+" </h3></a></li>";
            $("#mainMenu").append(cr);
            $("ul").listview("refresh");
            $.mobile.hidePageLoadingMsg();
            mainloaded = true;

        });
    }
}
http.send(null);

 });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读