我想使用load()方法將文本從.txt文件加載到HTML文檔中,但在代碼中找不到問題。文本文件與我的html文檔一起在桌面上。這裏是我的代碼:jQuery AJAX加載。()方法不適合我,我做錯了什麼?
HTML:
<script>
$(document).ready(function(){
$('#nav1').click(function(){
$('#target').load('textfile.txt');
});
});
</script>
</head>
<body>
<a href="#" id="nav1"> Load Button </a>
<div id="target"></div>
</body>
</html>
所有我在「TextFile.txt的」如下:
<h1> Heading 1 </h1>
<p> Some paragraph text. </p>
where'content'id –
$('#target')。load('textfile.txt'); –
嘗試一下ARUN說的話,如果這樣不能解決問題,你能指定一下你在嘗試這個時遇到的錯誤嗎? – ComputerLocus