【发布时间】:2010-11-06 17:29:54
【问题描述】:
$(document).ready(function() {
$('#content').html('');
$.ajax({
url:'data.json',
dataType: "json",
success: function(data) {
$('#content').append('<p>'+data.rank+'</p>');
}
});});
在这段代码中(有效)data.json 包含这种格式的 JSON 数据:
{
"user_id":"3190399",
"user_name":"Anand_Dasgupta",
"followers_current":"86",
"date_updated":"2009-06-04",
"url":"",
"avatar":"205659924\/DSC09920_normal.JPG",
"follow_days":"0","started_followers":"86",
"growth_since":0,
"average_growth":"0",
"tomorrow":"86",
"next_month":"86",
"followers_yesterday":"86",
"rank":176184,
"followers_2w_ago":null,
"growth_since_2w":86,
"average_growth_2w":"6",
"tomorrow_2w":"92",
"next_month_2w":"266",
"followersperdate":[]
}
此数据来自网址:
http://twittercounter.com/api/?username=Anand_Dasgupta&output=json&results=3
(点击网址获取数据)
但是当我将 $.ajax 函数中的 data.json 替换为包含相同数据的 URL 时,下面的代码似乎不起作用...
$(document).ready(function() {
$('#content').html('');
$.ajax({
url:'http://twittercounter.com/api/username=Anand_Dasgupta&output=json&results=3',
dataType: "json",
success: function(data) {
$('#content').append('<p>'+data.rank+'</p>');
}
});});
我们将不胜感激任何有关此问题的帮助。
感谢期待,
阿南德
【问题讨论】: