English 中文(简体)
jquery RecJSON不从事尿工作
原标题:jquery getJSON not working on url

我发现,为了活得分的展示,我发现了json url。

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

www.un.org/Depts/DGACM/index_spanish.htm json的输出:

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

我不知道在我的网站上如何取用和显示数据。

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

请让我提到我所做的错误。 我可以从<代码>json获取数据。 我无法与该网站连接。

预 收

最佳回答

采用这一方法,计分

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

也许意味着做一些事情:

for(var item in data) {
    alert(item +  :  + data[item]);
}

This gives you messages like "batting_team : Canada" and "date : Feb 28, 2011" which is probably more what you want.





相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签