我有以下 jquery 代码:
$(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");
}
});
});
});
从 url 中提取的 json 如下所示:
{"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"
}}
我的 jquery 只是拒绝输入 $.getJSON 函数,“enetered getJSON”警报不会触发。
怎么了?
解决了。谢谢你们 :)