标签:doctype oct 获取 doc cli 读取 ext 1.2 rip
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <style> </style> <title>read file</title> </head> <script src="jquery-1.11.2.js"></script> <script> $(function() { $("#btn1").click(function(){ $.ajax({ type: "get", url: "1.txt", dataType: "text", async: true }).done(function (data) { $("#one").html(data.replace(/\r\n/ig, ‘</br>‘));//替换回车行成换行符 //console.log(data.replace(/\r\n/ig,‘</br>‘)); }); }); }); </script> <body> <div id="one" style="width: 300px;background: greenyellow;margin: 10px;;"> </div> <input type="button" id="btn1" value="点击获取"/> </body> </html>
ajax读取文本内容(此处的txt文件和html文件处于同级目录)
标签:doctype oct 获取 doc cli 读取 ext 1.2 rip
原文地址:http://www.cnblogs.com/ch-n/p/6255716.html