Reading a txt file from Javascript
问题 am trying to read few lines from a txt file using JS,and i have this code but its not working for some reason,, var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.OpenTextFile("C:\\wamp\\www\\22.txt", 1, true); var row = s.ReadLine(); alert(row); any suggestions?! 回答1: If you're running WAMP anyway, just use standard AJAX to fetch the file 22.txt from the server. The easiest way is to use jQuery, where the code would be: $.get("22.txt", function(data) { alert(data); } You