(Handlebarsjs templating) How to get data from external JSON source?

纵然是瞬间 提交于 2019-12-11 21:34:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/19194008/handlebarsjs-templating-how-to-get-data-from-external-json-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!