Reputation: 441
I have the next code:
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "http://www.youtube.com");
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('master').innerHTML = xhttp.responseText;
}
};
xhttp.send();
I try the same with google and Facebook and it worked fine in browser and phone but youtube only works in Browser ¿What happened?
pd: browser = desktop browser
pd: pd: It enter in the if and does the innerHTML but in the phone the responseText doesn't return anything
Upvotes: 1
Views: 74
Reputation: 53301
It's probably because of the User Agent as http://www.youtube.com
redirects to http://m.youtube.com
the loading of the www is probably canceled and just return the empty response.
I've added this preference on my config.xml to use this desktop user agent and I get a response now.
<preference name="OverrideUserAgent" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" />
Upvotes: 1