html
<pre id="myText" style="word-wrap: break-word; white-space: pre-wrap; white-space: -moz-pre-wrap">
</pre>
发送ajax请求,请求到数据后,渲染在pre标签上,文本的换行回车,需要通过pre标签来读取,
/js
var url = "/public/aaa/cmd/123.txt";
$.ajax({
url: url,
async: false,
success: function (data) {
console.log(data);
$('#myText').html(data)
}
})
引自清风211,侵删