I'm trying to get some info from my XBMC server via javascript. Eventually my goal is to modify/expand this script and use it in tasker, but for now i'm just trying to get it to work in the browser. It works fine in IE and writes '{' to the screen as it should, but when I try to run it in chrome, req.onload never seems to be called. The same is true when i run a modified version on android/tasker. Any Ideas?
function main(){
var url = "http://192.168.1.85";
var command = '/jsonrpc?request={"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": { "sort": { "order": "ascending", "method": "artist", "ignorearticle": true } }, "id": 1}';
var http_timeout = 1200;
var req = new XMLHttpRequest();
req.open('GET', url+encodeURI(command), true);
req.timeout = http_timeout;
req.onload = function(e) {
if (req.readyState == 4 && req.status == 200) {
if(req.status == 200) {
document.write(req.responseText);
}
}
};
req.send(null);
}
TL;DR
This works in IE and not Chrome. Why?