I am writing a little Gadget that will show me the current status of my game server. It gets its information via an URL that returns JSON. At the beginning it worked fine. But now it seems to be stuck at the AJAX call.
This is my script:
function start() {
$("body").css({
height: "100px",
width: "130px",
margin: 0
});
$("#refresh").click(function (event) {
event.preventDefault();
fetch_info();
});
fetch_info();
};
function fetch_info() {
var now = new Date();
var msec = now.getTime();
ajax = new ActiveXObject("Msxml2.XMLHTTP");
ajax.open("GET", "http://the.amazing.url?msec="+msec, true);
ajax.onreadystatechange = function() {
if (ajax.readyState === 4) {
if (ajax.status === 200) {
var json = $.parseJSON(ajax.responseText);
if (json.map != "error")
{
$("#map").html(json.map);
$("#mode").html(json.gamemode);
$("#current").html(json.players);
$("#max").html(json.max_players);
}
else
{
$("#map").html("crashed");
}
} else {
$("#map").html("error");
}
}
else
{
$("#map").html("fetching data");
}
}
ajax.send(null);
}
When the widget starts it is showing "fetching data" but after that it happens nothing. It gets valid JSON Data.
Does anyone know why or a way to debug this script?