Results 1 to 7 of 7
  1.    #1  
    I've just created a new project through Komodo to try and mess around with AJAX a bit to aid another app I'm working on. However I keep getting this error whenever I run the program:

    error: Uncaught TypeError: Cannot read property 'apply' of undefined

    There's nothing actually in the application other than one scene with a simple div with an id to put the responsetext in it. The AJAX request runs in the activate method.

    I've searched around a bit and can only find one reference to it in some IRC logs with no proposed solution. Anyone else encountered this or have any clues as to what the problem might be?
  2. #2  
    code? - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  3.    #3  
    Here it is. I've changed it so that a button event fires it instead (just incase requests are not possible via activate method).


    function MainAssistant() {
    MainAssistant.prototype.setup = function() {
            { label: 'Test'},
    MainAssistant.prototype.activate = function(event) {
    MainAssistant.prototype.deactivate = function(event) {
    MainAssistant.prototype.cleanup = function(event) {
    // -------------------------------------------------------------------------- //
    MainAssistant.prototype.handle = function(item) {'SUCCESS');
        this.controller.get('content').innerHTML = item;
    }; = function(item) {'FAIL');;
    MainAssistant.prototype.buttonTap = function(event) {
                method: 'get',
                onSuccess: this.handle.bind(this),
  4.    #4  
    Ok, I've tried using standard XMLHttpRequest object to perform a request and it works, but the handler event fires 5 times...

    I'm a little confused and I can't find any decent documentation regarding dos and donts when it comes to AJAX on WebOS. Starting to feel frustrated.

    UPDATE: Ok, my bad, I forgot to check the readyState so of course the method fired once for every state change. However, I still cannot work out why Ajax.Request is returning the error that I mentioned in the first post.
    Last edited by semprance; 09/03/2010 at 07:40 PM.
  5. #5  
    Ajax works with JSON file instead of txt file.
    A json file is text file with a dedicated format.

    Here is an exemple:
    MainAssistant.prototype.buttonTap = function(event) {
    var url = Mojo.appPath + 'Database/My_File.json';
    	var request = new Ajax.Request(url, {
    	method: 'get',
    	evalJSON: 'force',
    	onSuccess: this.gotResults.bind(this),
    	onFailure: this.failure.bind(this)
    MainAssistant.prototype.gotResults = function(transport) {
    	var r = transport.responseJSON;
    	this.Item = r.Item;
       	this.controller.get('Item').innerHTML = this.Item;
    MainAssistant.prototype.failure = function(transport){
    Mojo.Controller.getAppController().showBanner($L("Item: ") + this.Item, "","Information");
    In the Main Assistant scene put :
    <div id="Item"></div>
    The My_File.json looks like:
        "Item": "Here is the description of Item"
    Note that the json file is stored on the folder "Database" of your application path.

    if you want more items, just add them in the json file and add IDs in the scene
    is ZE #1 innovative software solutions for PalmOS and Palm webOS.

  6.    #6  
    I'm trying to get data from an XHTML page so I need the request to return something that either can be turned into or already is a DOM document. Thanks though, as Ajax.Request will still be more convenient for when I'm dealing with JSON.
  7. #7  
    try setting 'evalJSON: false' - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.

Posting Permissions