(Handlebarsjs模板)如何从外部JSON源获取数据? [英] (Handlebarsjs templating) How to get data from external JSON source?

查看:172
本文介绍了(Handlebarsjs模板)如何从外部JSON源获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅此链接: http://jsfiddle.net/Rousnay/FJzre/ 它正在工作,JSON数据将通过 http://json.virtuecenter.com/json-data/blogs/tags?callback=?



但它不工作,当我想要从 http://sunday-theater-club.simpletix.eu/API/ThemeUIHandler.asmx/GetMenuItems?callback=?



任何人都可以通过 jsfiddle 示例来帮助我。 返回的数据对模板无效,从 http://sunday-theater-club.simpletix.eu/API/ThemeUIHandler.asmx/GetMenuItems?callback = 的?你最终得到:

  [
{
text:Home,
url:/Default.aspx
},
{
text:Events,
url:/ Event-List /
},
{
text:Test,
url:/ Pages / 8276 / Test /
}
]

当从 http://json.virtuecenter.com/json-data/blogs/tags?callback= ?您有:

  {
blogsTags:[
{
tag: GovernorBentley,
count:1,
separation_path:\ / blogs\ / byTag\ / GovernorBentley.html
},
{
tag:Huntsville,
count:1,
separation_path:\ / blogs\ / byTag\ / Huntsville.html
} ,
{
tag:投票责任,
count:1,
separation_path:\ / blogs\ / byTag\ / Voting Responsibility.html

{
tag:投票权,
count:1,
separation_path: \ / blogs \ / byTag \ / Voting Rights.html
}
],
分页:{
限制:20,
total:4,
page:1,
pageCount:1
}
}

您的模板需要一个blogsTags属性。


See this link: http://jsfiddle.net/Rousnay/FJzre/ it is working, the JSON data come trough http://json.virtuecenter.com/json-data/blogs/tags?callback=?

but it is not working when i want to get data from http://sunday-theater-club.simpletix.eu/API/ThemeUIHandler.asmx/GetMenuItems?callback=?

Can anyone help me with jsfiddle example. please.

解决方案

The returned data is not valid to the template, when getting from "http://sunday-theater-club.simpletix.eu/API/ThemeUIHandler.asmx/GetMenuItems?callback=?" you end up with:

[
    {
        "text": "Home ",
        "url": "/Default.aspx" 
    },
    {
        "text": "Events ",
        "url": "/Event-List/"
    },
    {
        "text": "Test",
        "url": "/Pages/8276/Test/"
    }
]

and when getting from "http://json.virtuecenter.com/json-data/blogs/tags?callback=?" you have:

{
    "blogsTags": [
                     {
                         "tag":"GovernorBentley",
                         "count":1,
                         "separation_path":"\/blogs\/byTag\/GovernorBentley.html"
                     },
                     {
                         "tag":"Huntsville",
                         "count":1,
                         "separation_path":"\/blogs\/byTag\/Huntsville.html"
                     },
                     {
                         "tag":"Voting Responsibility",
                         "count":1,
                         "separation_path":"\/blogs\/byTag\/Voting Responsibility.html"
                     },
                     {
                         "tag":"Voting Rights",
                         "count":1,
                         "separation_path":"\/blogs\/byTag\/Voting Rights.html"
                     }
                 ],
                 "pagination": {
                     "limit":20,
                     "total":4,
                     "page":1,
                     "pageCount":1
                 }
}

your template expects a "blogsTags" property.

这篇关于(Handlebarsjs模板)如何从外部JSON源获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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