Skip to content Skip to sidebar Skip to footer

Javascript Read From Text File

I have recently gotten into html, css, and javascript and am writing a simple website. I need to have an autocomplete textbox. I have a textfile in the same folder as the html and

Solution 1:

you need to use XMLHttpRequest for all browsers and IE7+. However, for IE6 you need to use AciveXObject. You can use get or post request and parse the string after you receive the response from server.

var responseStr; var xmlHttp=new XMLHttpRequest();

xmlhttp.open("GET","search.txt",true); xmlhttp.send();

xmlhtpp.responseText will have the contents of the file. You then further need to parse this.

Post a Comment for "Javascript Read From Text File"