私のメインHTMLファイルは、次のコンテンツを動的にロードします。
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
Loading please wait
<script type="text/javascript">
$(document).ready(function(){
$('body').load("remotePage.html");
});
</script>
</body>
</html>
remotePage.htmlは;
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="script1.js"></script>
<script type="text/javascript" src="script2.js"></script>
<script type="text/javascript" src="script3.js"></script>
</head>
<body>
<script type="text/javascript">
function init(){
someFunctionThatDependsOnAllScripts(); //Fails because all scripts is not yet loaded
}
$(document).ready(init);
<script>
</body>
</html>
script1.jsが読み込まれる前に、script1.jsのreadyが呼び出されるため、失敗します。ロード時にコールバックを設定しても効果がないようです。
$(function(){
$('body').load("remotePage.html", function(){
init(); //doesn't work either
});
});
remotePage.htmlに必要なリソースをロードするためのすべてのajax操作がいつ終了したかを知るにはどうすればよいですか?直し方?
ありがとう