Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 24
Registered: ‎04-20-2011
My Device: Playbook
Accepted Solution

Reading local txt file => string variable?

Could anyone please point me to a WebWorks example showing how to load the content of a local (=in the app folder) text file into a string variable? Thank you.

Posts: 51
Registered: ‎10-22-2011
My Device: 9800
My Carrier: Telus

Re: Reading local txt file => string variable?

I'm assuming that by "in the app folder" you mean in the bar file. If so, it requires an XHR request. I pulled the following from my app.
        var res;
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                res = xhr.responseText;
        // res now contains the contents.