How do I load the contents of a text file into a javascript variable?

后端 未结 9 810
南笙
南笙 2020-11-22 07:22

I have a text file in the root of my web app http://localhost/foo.txt and I\'d like to load it into a variable in javascript.. in groovy I would do this:

         


        
9条回答
  •  梦如初夏
    2020-11-22 08:24

    here is how I did it in jquery:

    jQuery.get('http://localhost/foo.txt', function(data) {
        alert(data);
    });
    

提交回复
热议问题