Question

why doesnt this ajax call doesnt work on my BB OS5 and works in 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>

.........

Am using jqm 1.1.1 version with jquery 1.7.2 this works on BB OS6+

Was it helpful?

Solution

Sorted :

Looks like BB OS5 has problem with jQuery-Ajax.. For someone who is trying the same try using 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, 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");
            $.mobile.hidePageLoadingMsg();
            mainloaded = true;

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

 });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top