<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js" type="text/javascript" charset="utf-8"></script>
<script src="app.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<ul>
<script id ="ajaxTemplate" type="text/x-handlebars-template">
{{#each}}
<li>
<span class="meta">{{name}} on {{date}}</span>
<p>{{comment}}</p>
</li>
{{/each}}
</script>
</ul>
<script>
$(document).ready(function(){
//document.write("Hello");
var data = [{
"name":"Name2",
"date":"12/12/1999"
}, {
"name":"Name1",
"date":"12/12/1999"
}]
var source = $.trim($('#ajaxTemplate').html());
var template = Handlebars.compile(source);
var html = template(data);
//document.write(html);
$('ul').append(html);
});
</script>
</body>
</html>
谁能告诉我上面代码中的错误是什么。我无法将编译后的 JS 代码附加到 DOM。