点击我试图通过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