Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
How to read a text file into a string variable in JavaScript? I have tried few of the solutions that are in the internet and none of have worked

I have tried few of the solutions offered in the internet and none have worked. Below couple of what I tried:

var client = new XMLHttpRequest();
client.open('GET', '/foo.txt');
client.onreadystatechange = function() {
    alert(client.responseText);
}
client.send();

var fs = require("fs");
fs.readFile(".esc_jose.txt", function(text){
    var textByLine = text.split("\n")
});

using the below code, I get no data from the alert().

var client = new XMLHttpRequest();
client.open('GET', '/esc_jose.txt');
client.onreadystatechange = function() {
  alert(client.responseText);
}
client.send();
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda