我知道這個問題已被問了好幾次,但我遇到了這個問題。 我想追加我的index.html文件與內容otherpage.html通過jquery追加HTML文件失敗
我的index.html的代碼是
<html>
<head>
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$.get("otherpage.html", function (data) {
$("#appendToThis").append(data);
});
});
</script>
</head>
<body>
<div id="appendToThis"></div>
</body>
而且我對otherpage.html代碼
<p>This is second page.</p>
當我打開Index.html時,我看到一個空白的白頁。任何人都可以請指出哪裏的錯誤是..在此先感謝
你不能在文件系統上執行ajax – mehulmpt
代碼對我來說工作正常。很可能你會得到一個CORS錯誤。嘗試將其加載到Web服務器中。 – APAD1
控制檯是否記錄任何錯誤? –