Problem:
I’m quite new user of Active Presenter, and I would like to know if it’s possible to read a text file, either in .ini or .xml or .json formatting, with ActivePresenter.
Regards,
ActivePresenter version:
9.0.6
OS:
Windows10
Notes:
Problem:
I’m quite new user of Active Presenter, and I would like to know if it’s possible to read a text file, either in .ini or .xml or .json formatting, with ActivePresenter.
Regards,
ActivePresenter version:
9.0.6
OS:
Windows10
Notes:
Hi,
Are you referring to HTML5 output?
If so, do you want ActivePresenter to read text files from the server side or the client side (HTML5 viewer device)?
Regards,
Hi,
In HTML5 output, Yes.
Regards
Thank you for your response and please also provide the information for the second question so we can assist you better: Where is your file? on a web server or on a viewer computer?
Regards,
Sorry l forgot : it’s on server side. Regards
Hi @pbouille,
You can use Fetch API to load a text file hosted on a server provided that the file is accessible from the HTML5 page (same origin or CORS enabled).
async function fetchTextFile(url) {
try {
const response = await fetch(url);
const text = await response.text();
// or const json = await response.json(); for json text file
} catch (error) {
console.error(error);
}
}
fetchTextFile('your/file/url');
Regards
Thnks @ToanLS , does this mean that Fetch API is usable in active presenter projects (exported in HTML5) ?
Regards
Yes, you can virtually use any client-side JavaScript feature with HTML5 output of ActivePresenter, not just the Fetch API.
Regards
Thanks for this message, but it doesn’t work for me. It seems that the file is read, but text remains empty. My file contains one sentence in text mode.
Any idea ?
Regards
You can press F12 to open the browser developer tools, then switch to Console tab to see if there’s any error messages there.
Regards
Thank you very much for this solution : now I can read the file, that was not in the good directory.
You have been very helpful.
Regards.
Philippe