目前我使用的follwing方式来填补我的js全局变量与由JSON获得的数据正确方法:填补通过Ajax请求的js变量
var tranlationJson =
$.ajax({
type: "GET",
url: "translation.xml",
contentType: "text/xml",
dataType: "xml",
success: function (dataSource) {
tranlationJson=ToJasonParser(dataSource);
}
});
有没有更聪明的方法?我需要填充这些变量,因为在稍后加载的脚本中,我使用它们的内容。
那不行;它是异步的。使用承诺。 – SLaks 2013-04-25 14:36:23