我的网站由两个页面组成。我想将第二个页面加载到第一个页面的div中,然后在单击时显示第二个页面。我正在尝试使用以下代码,但它不起作用。作为新手,如果这只是一个愚蠢的问题,请原谅我。
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({url:"myPage2.html",success:function(result){
$("#div1").html(result);
}});
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Get External Content</button>
</body>
</html>
#myPage2.html
吗? - tymeJV