Reading a txt file from Javascript

前端 未结 3 1984
猫巷女王i
猫巷女王i 2020-12-07 05:52

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.FileS         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 06:07

    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 can search for how to do this without jQuery if you wish.

提交回复
热议问题