點擊我試圖通過URL從JSON獲取數據到<div>
。點擊獲取JSON數據到DIV
我的JSON返回一個單一的ID和內容,我試圖讓內容進入div #west-container
。
有人能告訴我我做錯了什麼嗎?
我的JSON在URL找到= [{"id":"2","title":"Generic Overview","content":"This is content here"}]
$('#jqxTree').bind('select', function (event) {
var loadPages = jQuery.parseJSON(
jQuery.ajax({
url: 'university/article/3',
async: false,
dataType: 'json'
}).responseText
);
for(i=0; i < loadPages.length ; i++){
var current = loadPages;
$("#west-container").load(current.content);
}
});
爲什麼不使用[的getJSON(http://api.jquery.com/jQuery.getJSON/)? – Stefan
爲什麼不使用'$ .ajax()'的成功函數? – Jai
是這個命令jQuery.ajax({url:'university/article/3', async:false, dataType:'json' })。responseText alone you get this line?{「id」:「2 「,」標題「:」通用概覽「,」內容「:」這裏是內容「} – HiDd3N