我的应用程序需要静态翻译。我已经在json文件中输入了翻译。我想在加载js文件之前加载这个json文件。我该怎么做?任何帮助将不胜感激。
答案 0 :(得分:1)
我个人不会依赖订单,脚本会加载到文档中,但使用像domready-event这样的机制,甚至更像require.js。使用require.js,你可以加载你的JSON,之后做你的JS。
domready-event:https://learn.jquery.com/using-jquery-core/document-ready/
require.js:requirejs load static JSON file
答案 1 :(得分:0)
/usr/src/<kerne_path>
答案 2 :(得分:0)
你可以这样做:
$(function(){
$.ajax({
dataType: "json",
url: 'path/to/json/file.json',
success: function(result){
start(result)
}
});
});
function start(data /*converted to javascript object*/ ){
// you can process the JSON result first
// and call other functions after this point
}