jQuery getJSON在URL上不起作用 [英] jquery getJSON not working on url

查看:206
本文介绍了jQuery getJSON在URL上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了可实时显示乐谱的json网址

I had found json url for live display of scores

http://json-cricket.appspot.com/score.json

json的输出:

{
 "batting_team": "Canada", "date": "Feb 28, 2011",
 "match": "Canada vs Zimbabwe", "score": "Canada 106-8 (37)",
 "summary": "Z Surkari(21) H Baidwan(3)*" 
}

我不知道如何使用以下代码在我的网站中获取和显示数据:

I don't know how to fetch and display the data in my site I am using following codes:

$.getJSON("http://json-cricket.appspot.com/score.json", function (data) {
    $.each(data, function (i, set) {
        alert("Batting Team: "+set.batting_team);
    });
});

请提及我我做错了什么.我无法从json获取数据.我无法连接到该站点.

Please mention me what wrong I did. I can't get the data from json. I am not being able to connect to the site.

预先感谢

推荐答案

嘿,我使用此方法获取了板球得分,

Hey I Fetched cricket score using this,

var url="http://json-cricket.appspot.com/score.json?callback=?";
$.getJSON(url, function (data) {
    for(var item in data) {
        alert(item + ':' + data[item]);
    }
});

这篇关于jQuery getJSON在URL上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆