I am attempting to retrieve data in JSON format from an API using AngularJS. The process is successful on iOS and desktop browsers, but I'm encountering a strange response when trying it on my Android device. The request code looks like this:
$http({
url: baseUrl,
method: "GET",
headers: {
"Content-Type": "application/json"
},
params: {
authKey: myAuthKey,
id: myId,
format: "json"
}
})
.success(function(data, status){
console.log("Success", data); // The output differs on Android
orderData(data);
})
.error(function(data, status){
console.log("Error");
console.log(data,status);
});
The request always succeeds and returns an object as expected on iOS and desktop browsers. However, when I check the data on my Android device, the result is unexpected and appears to be HTML code related to a router:
> Success <html>
> <head>
> </head>
> <body>
> <script>
> var wwwurl='www.mywifiext.com/welcome.htm';
> function check_mobile_device()
> {
> if(navigator.userAgent.indexOf("iPhone") != -1)
> return 1;
> else if(navigator.userAgent.indexOf("Android") != -1)
> return 1;
> else if(navigator.userAgent.indexOf("Windows Phone") != -1)
> return 1;
> else if(navigator.userAgent.indexOf("iPad") != -1 )
> return 0;
> else
> return 0;
> }
> if(check_mobile_device() == '1')
> top.location.href="http://www.mywifiext.net/mobile_welcome.htm";
> else
> top.location.href="http://www.mywifiext.net/welcome.htm";
> </script>
> </body>
> </html>
This unusual HTML response seems to be linked to a specific router. I have tested it on various Wi-Fi networks and even with the device's 3G connection.
I recently integrated Crosswalk into my project, which utilizes the cordova-plugin-whitelist
. Could this integration be causing the issue? Or is it possible that there is a bug on the API side?
EDIT: Reverting back to the default browser resolved the issue. But why did it happen? How can I make it work with Crosswalk?