我试图从外部文件加载,但它没有这样做。
这个jQuery文件是test.html。 数据文件是data.html。
两者都在同一个文件夹中。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#btn_01").click(function()
{
$("#p1").load("data.html");
alert("Hey, jQuery has loaded succesfully!");
});
});
</script>
</head>
<body>
<!-- Buttons -->
<button id="btn_01">Get Content From Server</button>
<!-- Paragraphs -->
<p id="p1">Content from the server displayed below:</p>
</body>
data.html:
<html>
<body>
<p id="my_p1">Here is some content to display.</p>
<p id="my_p2">Here is some more content to display.</p>
</body>
</html>