具有这种结构的 Json 数据:
Title_day_hourminsec([
{"data":"x", "type":"y"},
{"data":"x", "type":"y"},
{"data":"x", "type":"y"},
{"data":"x", "type":"y"},
{"data":"x", "type":"y"},
{"data":"x", "type":"y"},
]);
从 jquery getJSON 的调用中,我无法获取文件的真实内容,只得到了 html 输出:
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
这是我试图获取 json 内容的 javascript 片段:
<script type="text/javascript">
$(document).ready(function(){
$.getJSON("myremotedata",
function(data){
var items = [];
$.each(data, function(key, val) {
items.push('<li id="' + key + '">' + val + '</li>');
});
$('<ul/>', {
'class': 'my-new-list',
html: items.join('')
}).appendTo('body');
});
});
</script>
我错过了什么?