我正在尝试从html文件中获取数据。我正在使用AJAX,但我无法将数据传递到全局函数空间。功能代码
var loadTemplate = function(file_name){
var template;
$.get('/static/templates/'+file_name+'.html', '', function(res){ template = res; });
console.log(template);
return template;
}
返回未定义的对象;
你能给我最好的解决方案吗?我正在使用doT.js模板引擎(http://olado.github.io/doT/index.html)。我需要从我的服务器加载模板。 doT引擎只编译字符串文本