Software Archive
Read-only legacy content
Announcements
Important Update: Community Platform Migration​. Learn more​>
17060 Discussions

xhttp.status returning 0 on Android

Joao_V_
Beginner
3,134 Views

My Application need to connect to an server, it works on IOS, but on Android not.

On IOS they return code 200, 404 etc

On Android they only return 0, for error, succes, anything!

 

My code:

     var xhttp = new XMLHttpRequest();
              xhttp.open("GET", HTTP, true);
        xhttp.onreadystatechange = function() {
            alert(xhttp.status);
    if ((xhttp.readyState == 4 && xhttp.status == 200) || (xhttp.readyState == 4 && xhttp.status == 0)) {
      document.getElementById("SIFrame").value = xhttp.responseText;
        TA = TXTIFrame.value;
        lines=TA.split("\n");
        document.getElementById("LineE").innerHTML = lines[LE];
        A1B.innerHTML = lines[R1];
        A2B.innerHTML = lines[R2];
        A3B.innerHTML = lines[R3];
        A4B.innerHTML = lines[R4];
        A5B.innerHTML = lines[R5];
         activate_page("#readerpage");
    
                
    } else {
        if(MSG == false && xhttp.status == 404) {
                    alert("Esse arquivo não pode ser encontrado, verifique sua conexão com a internet!")
                    MSG = true;
        }
    }

Thanks for the help!

0 Kudos
1 Solution
Hamilton_Tenório_da_
Valued Contributor I
3,134 Views

@Joao> maybe this post helps you: https://software.intel.com/en-us/comment/1867247#comment-1867247, thread Paul F. (Intel)  Wed, 04/06/2016 - 08:57

View solution in original post

0 Kudos
2 Replies
Hamilton_Tenório_da_
Valued Contributor I
3,135 Views

@Joao> maybe this post helps you: https://software.intel.com/en-us/comment/1867247#comment-1867247, thread Paul F. (Intel)  Wed, 04/06/2016 - 08:57

0 Kudos
Elroy_A_Intel
Employee
3,134 Views

I recommend that you add add an * (asterisk) to the network request field and http://* in the intent field on the projects panel. These configuration settings are visible for Cordova projects under the Build settings sections for the desired mobile platform. After you have successfully tested your project, the appropriate domain name (http://my-server.com) to the intent field. If your have more domain names, add them to the field separated by commas. 

0 Kudos
Reply