1
我是YUI的新手,無法找到如何解決此問題。我使用從YUI的例子代碼,並試圖讓我的JSON網址工作..「沒有數據顯示」,而將JSON數據填充到YUI數據表
<div id="pizza" class="yui3-skin-sam dt-example"></div>
<script>
YUI().use("datasource-get", "datasource-jsonschema", "datatable-base-deprecated", "datatable-datasource-deprecated", function (Y) {
var url = "http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo",
dataSource,
table;
dataSource = new Y.DataSource.Get({ source: url });
dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
schema: {
resultListLocator: "geonames",
resultFields: ["fcodeName", "toponymName", "countrycode", "fcl", "fclName", "name", "wikipedia", "lng", "fcode", "geonameId", "lat", "population"]
}
});
table = new Y.DataTable.Base({
columnset: ["fcodeName", "toponymName", "countrycode", "fcl", "fclName", "name", "wikipedia", "lng", "fcode", "geonameId", "lat", "population"] });
table.plug(Y.Plugin.DataTableDataSource, { datasource: dataSource });
table.render("#pizza");
table.datasource.load({ request: url });
});
</script>
和我的JSON響應是
{"geonames":[{"fcodeName":"capital of a political entity","toponymName":"Mexico City","countrycode":"MX","fcl":"P","fclName":"city, village,...","name":"Mexiko-Stadt","wikipedia":"","lng":-99.12766456604,"fcode":"PPLC","geonameId":3530597,"lat":19.428472427036,"population":12294193}, same pattern....]}
我覺得我缺少一些基本概念。如果這個問題沒有道理,我很抱歉。
喜thanx的答覆,如果我是正確的要拆分的URL,它是工作:(我有另一個URL(休息:https://開頭somedomain。它看起來像這樣[{「fcodeName」:「政治實體的大寫」,「toponymName」:「墨西哥城」,「墨西哥城」 countrycode「:」MX「,」fcl「:」P「,」fclName「:」城市,村莊,...「,」名稱「:」Mexiko-Stadt「,」維基百科「:」「,」lng「: -99.12766456604,「fcode」:「PPLC」,「geonameId」:3530597,「lat」:19.428472427036,「population」:12294193},相同模式....]現在如何處理resultListLocator,url,query。sry在這裏問這個 – Rony
嘗試'query ='';'並且保持代碼的其餘部分不變³ – teddybeard
您好,請您看看這個小提琴http://jsfiddle.net/TdFqz/我試圖做我的休息網址。但我無法獲取數據。我嘗試了你的建議。對於其他網址有效嗎?我只是模擬了我的休息通話數據。 – Rony