html中的js获取txt文件中的文字显示在html页面中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<pre id="text"></pre>
<script type="text/javascript">
$.ajax({
url: "123.txt",
type: "get",
dataType: "text",
success: function (data) {
$("#text").text(data);
},
error: function (jqXHR, status, thrown) {
alert(thrown);
}
});
</script>
</body>
</html>