Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

296
Views
¿Cómo cargar un archivo de texto externo en JavaScript Word API?

Estoy tratando de cargar un archivo de texto para analizarlo e insertarlo en el documento de ms, pero los métodos estándar de JavaScript no parecen funcionar.

He intentado

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

e intenté acceder por

 document.getElementById("file-id").files[0]

pero HTMLElement no tiene la propiedad 'archivos' en la API de Word

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Recomendé usar fetch() para cargar todos los archivos como .txt en JavaScript.

Para texto:

 fetch('foo.txt').then(x => x.text()).then(y => alert(y));

Para JSON:

 fetch('foo.txt').then(x => x.json()).then(y => alert(y));

Para imágenes:

 fetch('me.jpg').then(x => x.blob()).then(y => document.getElementById('demo').src = URL.createObjectURL(y));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!