我正在尝试使用以下代码,但它失败并出现错误:Uncaught SyntaxError: Unexpected identifier, on the line:
$.get("commonCore/templates/" + data[i].templateHtml ,function(html)
有人可以帮我调试它。我对 javascript 和 jquery 非常陌生
JSON:
[{"templateHtml":"dashBoardLeftInsight.html","classSelect":"leftpanel"},{"templateHtml":"dcdcsFilterOptions.html","classSelect":"dcdcsOptions"},{"templateHtml":"advanceFilterOptions.html","classSelect":"advancedOptions"},{"templateHtml":"reportFilterOptions.html","classSelect":"reportdashboard"}]
代码 :
$.getJSON('api/filterTemplate/dashboard',function (data){
var a = new Array(data.length);
console.log(data.length);
$.when(function(){
for(var i=0;i<=data.length,i++)
{
$.get("commonCore/templates/" + data[i].templateHtml ,function(html){
a[i]=html;
});
}
}).then(function(d){
for (var j=0;j<data.length;j++)
{
filterTemplate=Handlebars.compile(a[j]);
replaceFilterTemplate(data[i].classids[j]);
}
})
}
);