I have seen some other questions about it but nothing that solve my problem. I am using the code below to make a ajax request on phonegap 2.9.0. The cross domain permission is fixed. Running on my browser, the script is perfect. But when it comes to Android It runs all the code but the responseText get empty.

var request = new XMLHttpRequest(); 
    request.open("GET", url, true); 
    request.onreadystatechange = function(){ 
        if (request.readyState == 4) { 
            if (request.status == 200 || request.status == 0) { 
                $("#app").html(request.status + request.responseText);
            }                 
        } 
    } 
    request.send(); 

So, as you can see in the code, the #app element receive the request.status value 200 but the responseText is empty on android device, but in the browser is works fine. It shows the data that I am looking for. Anyone knows what is this?

有帮助吗?

解决方案

I have solved the problem. I made 2 changes: 1 changed the version of phonegap to 2.5.0 and called the file not as json, but as text and then use JSON.parse to make it be understandable. And then it works!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top