How can I parse a text file using javascript

前端 未结 3 724
北荒
北荒 2020-12-09 11:40

The code below is to read a text file using javascript. it works. However, I just want to read part of the content. For example, the content of the file is :\"Hello world!\

3条回答
  •  难免孤独
    2020-12-09 12:14

    Try this to read separate words if I understood correctly what you need. Create a file with the contents "hello world" and browse to it with the example script. The output is "hello".

    
    
    
    
    
    
    
    
    

    Reading directly has to be with an ajax request due to the javascript restrictions regarding safety. This code shoudl perform the requested operation:

    
    
    
    
    
    
    
    
    

提交回复
热议问题