Import Text File Using Javascript

后端 未结 2 449
后悔当初
后悔当初 2021-01-06 05:29

I am currently working on an application that handles a fairly large amount of data. Currently, I\'ve hard-coded those values into the Javascript iself (defining global arra

2条回答
  •  难免孤独
    2021-01-06 05:44

    Use AJAX. I suggest encoding the file in JSON format, rather than plain text. If you use jQuery, you can then use $.getJSON('filename.txt') to read the file and parse it into a Javascript object in one operation.

提交回复
热议问题