project readLocalFileByJQueryOnFirefoxBrowser
- index.html
- loadLocalFile.js
- htmlEle.txt
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
</head>
<body>
<div id="myContainer">
</div>
<script src="loadLocalFile.js"></script>
</body>
</html>
$.get(‘htmlEle.txt‘, function(data) {
console.log("p")
var lines = data.split("\n");
$.each(lines, function(n, elem) {
$(‘#myContainer‘).append(‘<div>‘ + elem + ‘</div>‘);
});
});
<h1>I will give the service you asked</h1>
Final Fact: skipped
how to read local file via using js in the browser
原文:https://www.cnblogs.com/1river/p/14515332.html