1. 方法一(图一):使用chrome浏览器,关掉浏览器,通过截图的两条命令运行chrome浏览器,再运行test.html文件。方法二(图二):选择chrome浏览器快捷方式,右键选择属性,再点击快捷方式,在目标"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"的后面加空格,输入 --allow-file-access-from-files,点击应用,重新启动浏览器,运行HTML文件即可。
2. test.html源码如下,注意load方法里的文件路径要写对。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="jquery/jquery-3.3.1.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("#test").load("example/jquery/test.log");
});
});
</script>
</head>
<body>
<p id="test">这里显示本地文本内容</p>
<button id="btn1" type="button">本地加载</button>
</body>
</html>