Javascript 车把没用?
我一辈子都搞不清楚我做错了什么 这是我的HTML/JS:Javascript 车把没用?,javascript,jquery,html,ajax,handlebars.js,Javascript,Jquery,Html,Ajax,Handlebars.js,我一辈子都搞不清楚我做错了什么 这是我的HTML/JS: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script src="handlebars-v1.1.2.js"></script> <script>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="handlebars-v1.1.2.js"></script>
<script>
$(document).ready(function(){
var jsonString = null;
$.getJSON("data.json", function(data) {
jsonString = data;
});
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
});
</script>
</head>
<body>
<script id="items" type="text/x-handlebars-template">
<span>{{Title}} : {{CSCI}}</span>
</script>
<ul>
</ul>
</body>
</html>
我得到的唯一输出是“:”所以它做得很好。控制台没有显示任何内容(例如完全为空,所以我假设任何地方都没有语法错误?)
我不喜欢发布这样的问题,因为这通常是因为我在某个地方犯了一个小错误,但我知道你们喜欢这些东西;) As
getJSON
是一个异步函数调用,您需要在成功回调函数中编译handlebar
$(document).ready(function(){
var jsonString = null;
$.getJSON("data.json", function(data) {
jsonString = data;
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
});
});
由于
getJSON
是一个异步函数调用,您需要在成功回调函数中编译handlebar
$(document).ready(function(){
var jsonString = null;
$.getJSON("data.json", function(data) {
jsonString = data;
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
});
});
由于
getJSON
是一个异步函数调用,您需要在成功回调函数中编译handlebar
$(document).ready(function(){
var jsonString = null;
$.getJSON("data.json", function(data) {
jsonString = data;
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
});
});
由于
getJSON
是一个异步函数调用,您需要在成功回调函数中编译handlebar
$(document).ready(function(){
var jsonString = null;
$.getJSON("data.json", function(data) {
jsonString = data;
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
});
});
getJSON是异步的,因此
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
所有这些都应该在回调内部getJSON是异步的,等等
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
所有这些都应该在回调内部getJSON是异步的,等等
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
所有这些都应该在回调内部getJSON是异步的,等等
var source = $("#items").html();
var template = Handlebars.compile(source);
$("ul").append(template(jsonString));
也应该都在回调内部