i tried a lot for this, but didnt find the answer . How can i read a file using javascript or html . I have a text file “sample.txt” and i have some information in it . It is placed in the same folder as the html file is placed where the html file contains the html code that deals with this file . I just want to read the information from the file and display it on some div or whatever, i mainly want to know how to read a file .
Will provide more information if necessary .
Thanks
At first: JavaScript is executed on client-side. Though you have to put up an AJAX-Request to fetch the content of your file. I think jQuery’s
load()seems to be the easiest way to achieve this.For example: