About the art of building metaphoric solutions to real world problems.
20 Oct
First be sure that the file you want to read is JSON syntax.
Then it’s a shot “with the bullet though the back into the eye”, as we say in germany:
// Getting gile myFile.json file
var file = Mojo.appPath + 'myFile.json',
fileFromAJAX = new Ajax.Request(file, {
method: 'get',
parameters: '',
evalJSON: 'force',
onSuccess: this.fileReadCallback.bind(this),
onFailure: this.fileReadErrorCallback.bind(this)
});
MainAssistant.prototype.fileReadCallback = function(transport) {
var resp = transport.responseJSON;
this.myVar = resp.myVar; //Here you can access your variables in your json file.
};
That’s it.
I hope they will change this in future versions of WebOS.

Leave a reply