내 메인 HTML 파일이 콘텐츠로 동적으로로드됩니다.JQuery AJAX load() & ready()
<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가 호출되기 때문에 실패합니다. 로드시 콜백이 도움이되지 않습니다.
$(function(){
$('body').load("remotePage.html", function(){
init(); //doesn't work either
});
});
remotePage.html에 필요한 리소스를로드하기위한 모든 아약스 작업이 완료되면 어떻게 알 수 있습니까? 해결 방법?
감사합니다 이것에
먼저 jQuery 라이브러리를 포함 할 필요가 ... –