[英]Generating Jquery Mobile site from Json
使用jQuery Mobile我想使用下面的json生成頁面。 通過生成我的意思是這個json代表整個移動站點的布局和結構。 我想以某種方式遍歷此數據(客戶端站點)並創建包含頁面列表和頁面的主頁。 有人可以通過一個例子讓我開始這個。
非常感謝
{
"name": "My Site Name",
"logo": "",
"theme": "a",
"fullSiteLink": "http://www.google.com",
"pages": [
{
"id": "1364666933727",
"name": "I'm a page",
"type": "basic",
"components": {
"img": "url here",
"text": "This is the page content."
}
}
]
}
首先嘗試編寫一個頁面,然后創建一些占位符並編寫一個腳本,用JSON中的數據填充它們。
要獲取JSON數組,請使用$.ajax
。
$.ajax({
Type: "GET",
url: URL,
dataType: "json",
contentType: "application/json",
success: function(data) {
$.each(data, function(index, value) {
// your code here
});
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.