Borache Borache - 1 year ago 57
HTML Question

reading a text file line by line only with javascript

I don't want solution using Node.js, FileReader, or whatever else exept javascript!
Developing the html page, I encountered a problem as follows:
I get accurate results with this procedure, unfortunately the procedure remembers result of the first login page. Whatever text file in the meantime change the content, the procedure returns the first result.
Can someone give advice!

var filePath = "../../dir/sub dir/text_file.txt";
function getBackData(filePath){
var axd, i, artx, txli, tdr;
axd = new XMLHttpRequest();
axd = new ActiveXObject("Microsoft.XMLHTTP");
}'GET', filePath, true);
axd.onreadystatechange = function(){
if(axd.readyState == 4 && axd.status == 200){
artx = axd.responseText;
txli = artx.split("\n");
for(i = 0; i < txli.length; i++){

Answer Source

You could try :axd setRequestHeader('Cache-Control', 'no-cache');

Or try:'GET', filePath+'?_=' + new Date().getTime()), true); This will prevent your server from using the cash, because each request is different.