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

300
Views
How to load external text file in JavaScript Word API?

I'm trying to load text file to parse it and insert into ms-document, but standard JavaScript methods doesn't seem to work.

I've tried

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

and tried accessing by

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

but HTMLElement doesn't have 'files' property in Word API

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

0

I recommended using fetch() to load all files like .txt in JavaScript.

For text:

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

For JSON:

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

For images:

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!