I have the following jquery code:
$(document).ready(function()
{
$('button').click(function()
{
$.getJSON('http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/server/status?output=json', function(json)
{
alert("Entered getJSON");
$("#output").append("working...");
if(json.status.indexOf("success")===0)
{
alert("success");
$.each(json.results, function(i, data)
{
$("#output").append(data.text);
});
}else
{
alert("Failed to load url");
}
});
});
});
The json that is pulled from the url looks like:
{"worldServerStatus": {
"customMessage": "",
"lastChangedDate": {
"date": 31,
"day": 4,
"hours": 17,
"minutes": 48,
"month": 4,
"nanos": 0,
"seconds": 32,
"time": 1338486512000,
"timezoneOffset": 0,
"year": 112
},
"localizedMessage": "The servers are currently up and running.",
"message": "ALL_SYSTEMS_GO",
"status": "UP"
}}
My jquery just refuses to enter the $.getJSON function, the "enetered getJSON" alert doesn't fire.
What is wrong?
Solved. Thank you all :)