【发布时间】:2015-03-08 06:09:47
【问题描述】:
为了隐藏 JSON 数据(以便以后可以淡入),我修改了 a1.start 函数,创建了名为“加载”的 div,但在 Chrome 的 Javascript 控制台中,有
Uncaught SyntaxError: Unexpected token ILLEGAL
在 HTML 中:a1.start($("#cakeHook"),"a1data.json");
<!doctype html>
<html>
<head>
<style>
</style>
<title>Cake Baby Bakery</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="a1.js"></script>
<link href="css/bootstrap.css" rel="stylesheet"/>
<link href="css/basica1.css" rel="stylesheet"/>
</head>
<body>
<div id="cakeHook" ></div>
<script>
a1.start($("#cakeHook"),"a1data.json");
</script>
</body>
</html>
a1.start
a1.start = function(hookElementSelection, dataurlForJsonFile) {
jQuery('<div/>', {
id: 'loading',
text: 'Loading...'
}).appendTo('hookElementSelection');
$('hookElementSelection).hide();
a1.products = {};
a1.recipes = {};
a1.suppliers = {};
a1.bakedRecipes = [];
//make an ajax call and wait for success
$.ajax({url:dataurlForJsonFile}).success(function(data) {
//get the recipe data
parseJSONData(data);
//put the recipes on the page
$.each(a1.recipes, function(i, recipe) {
recipe.render(hookElementSelection);
});
renderCalculator(hookElementSelection); //add in the final calculation logic
});
};
【问题讨论】:
标签: javascript jquery html