【发布时间】:2020-05-20 19:48:23
【问题描述】:
我在 .hbs 文件中有这个
<div class="col-12 col-md-3 order-md-1">
<div id="notes">
{{#each notes}}
{{>note}}
{{/each}}
</div>
</div>
这是我的 jquery:
$.ajax({
url: '/search/notes',
method: 'GET',
data: {
search_string: 'server'
},
success: function(response) {
var source = $('#notes').html()
var template = Handlebars.compile(source)
var context = {
notes : response.notes,
}
var el_html = template(context);
console.log(el_html)
$('#notes').html(el_html)
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>
我无法在id="notes" 上获得notes。它导致空白div。有什么帮助吗?
【问题讨论】:
标签: jquery node.js ajax handlebars.js