我知道这是可能的,并且我已经看过很多例子。我担心我已经知道了我的问题的答案,但也许我错过了什么。
我认为这不起作用是因为我正在本地运行此代码,而不是在服务器上运行。
在我的头标签中:
<script type="text/javascript" src="jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#test").load("test.html");
} );
</script>
在我的``标签中:
<div id="test"></div>
我的外部代码(在“test.html”内)
<div>This is what you should be seeing!</div>
这应该可以工作吧? 此外,在我的外部HTML文档中,我需要设置所有额外的标签,以便文档看起来像这样:
<html>
<head>
<title>
</title>
</head>
<body>
<div>This is what you should be seeing!</div>
</body>
</html>
我的所有文件都在同一个目录中。
谢谢。