안에 html 파일 ("hello_world.html")을로드하고 싶습니다. 다른 HTML 페이지 ("index.html")는 같은 위치에 있습니다. 이것은 내가 작성한 코드입니다. 하지만 아무것도로드하지 않습니다. 두 경고가 작동합니다 (나는 jquery가 작동하는지 여부를 확인하기 위해 의도적으로 사용함). 코드의 오류는 무엇입니까? 나는 아약스를 사용하고 싶지 않다. "브라우저에서jquery를 사용하여 다른 HTML 페이지를로드하는 중
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$("document").ready(function() {
$('#container').load('helloworld.html');
});
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>
로드 test.html를가 생산
인 HelloWorld.html
<p>hello!</p>
인 test.html :
</head>
<script type="text/javascript" src="../jquery-1.3.2.js"></script>
<script type="text/javascript">
$("document").ready(function() {
alert("ya loaded");
$('#container').load('hello_world.html');
alert("finished");
});
</script>
</head>
<body>
<div id="container">
</div>
</body>
'.load'가 비동기이기 때문에'.load'가 작동하지 않아도 경고 메시지가 출력됩니다. 그리고 당신은 AJAX를 사용하고 있습니다. –
디버깅 콘솔에서 어떤 오류가 발생합니까? 요청이 전송됩니까? 응답은 무엇입니까? –
AJAX를 사용하지 않으려면 서버 측 기술을 사용하여 클라이언트 브라우저에 전달되는 html에 hello_world.html을 포함시켜야합니다. – Aaron