HTML - read .txt file from URL location in javascript

前端 未结 2 794
傲寒
傲寒 2021-01-04 13:14

I want to read a .txt file an URL location, lets say from http://www.puzzlers.org/pub/wordlists/pocket.txt and process its content on my page.

Can you point me out

2条回答
  •  无人及你
    2021-01-04 13:27

    from codegrepper using fetch (unsupported on IE).

    const url = "http://www.puzzlers.org/pub/wordlists/pocket.txt"
    fetch(url)
       .then( r => r.text() )
       .then( t => //process your text! )
    

提交回复
热议问题