Hi guys I would like to know how I can read a text file from javascript
Hi guys I would like to know how I can read a text file from javascript
We must verify the status with 4 (zero)
function leeArchivo(file)
{
var archivo = new XMLHttpRequest();
archivo.open("GET", file, false);
archivo.onreadystatechange = function ()
{
if(archivo.readyState === 4)
{
if(archivo.status === 200 || archivo.status == 0)
{
var Texto = archivo.responseText;
alert(Texto);
}
}
}
archivo.send(null);
}
// We call the function passing as a parameter the path of the file to load link :
leeArchivo("http://web/archivo.txt");