$ .getjson无法将数组对象附加到html [英] $.getjson not able to append the array objects to html
本文介绍了$ .getjson无法将数组对象附加到html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的json数据如下所示
Hi my json data is like below
[{
"menu": "File",
}, {
"menu": "File1",
}]
我已经编写了jquery代码,将响应附加到html如下
I have written jquery code to append the response to html like below
$(document).ready(function () {
$.getJSON('data.json', function (data) {
var template = $('#personTpl').html();
var html = Mustache.to_html(template, data);
$('#sampleArea').html(html);
});
});
胡子模板在下面:
<script id="personTpl" type="text/template">
<h1>{{menu}}</h1>
</script>
请帮助
推荐答案
这应该是您的JSON:
This should be your JSON:
[
{
"menu": "File"
},
{
"menu": "File1"
}
]
这篇关于$ .getjson无法将数组对象附加到html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文