Results 1 to 3 of 3
  1. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #1  
    Can anyone advise why, when running the following code in a scene:

    Code:
    MainAssistant.prototype.setup = function() {
    	var mainElement = this.controller.get("main");
    	mainElement.innerHTML = "Test";
    	Mojo.Log.info("making request....");
    	var trendsURL = "http://search.twitter.com/trends/daily.json?date=2009-10-26";
    	var request = new Ajax.Request(trendsURL, {
            method: "get",
            onSuccess: this.checkSuccess.bind(this),
            onFailure: this.checkFailure.bind(this)
        });
    };
    
    MainAssistant.prototype.checkSuccess = function(trasport){
    	Mojo.Log.info("something worked....");
    	var mainDiv = this.controller.get("main");
    	mainDiv.innerHTML = transport.responseText;
    };
    
    MainAssistant.prototype.checkFailure = function(trasport){
    	Mojo.Log.info("something went wrong....");
    	var mainDiv = this.controller.get("main");
    	mainDiv.innerHTML = "<b>Something went wrong!</b>";
    };
    I see the scene with the word "TEST" in it, and get "making request...." in the log output, but never get either the log output from the checkSuccess or checkFailure methods.....
    Im running the latest version of the SDK and deploying to the emulator....

    Any advice welcomed from a newbie to webos development
    All very basic I know, I just dont know why it isnt working....
  2. #2  
    The input parameter of the checkSuccess and checkFailure methods is spelled "trasport"; however in the code you reference it as "transport".

    As far as the Mojo.Log.info statements...this may be a silly question, but have you set up your framework_config.json file to allow the log statements to print? To print out all log statements (info, warning, and error), you would have the following in the framework_config.json file:

    Code:
        {
            "logLevel": 99
        }
    You can read about logging here: Palm Mojo Framework - Mojo.Log
  3. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #3  
    Thanks for that. Schoolboy error!!!!!
    I've got logging enabled and I'm seeing my Log.info messages, so thats all well....

    The checkSuccess function is now being called, as I'm getting the log from that method:

    Code:
    MainAssistant.prototype.checkSuccess = function(transport){
    	Mojo.Log.info("something worked....");
    	var mainDiv = this.controller.get("main");
    	eval(transport);
    	//var twitData = transport.evalJSON();
    	mainDiv.innerHTML = trends[0].name;
    	
    };
    but my mainDiv isn't getting anything populated from the returned JSON.
    Here's an example of what twitter returns:

    Code:
    {"trends":
    	{"2009-10-30 18:05":[
    		{"name":"Follow Friday","query":"\"Follow Friday\" OR \"#follow Friday\""},
    		{"name":"Happy Halloween","query":"\"Happy Halloween\" OR #Halloween"},
    		{"name":"Google Wave","query":"\"Google Wave\""},
    		{"name":"HIV","query":"HIV"},
    		{"name":"Twitter Lists","query":"\"Twitter Lists\" OR Lists"},
    		{"name":"#britney3premiere","query":"#britney3premiere"},
    		{"name":"this is it","query":"\"this is it\""},
    		{"name":"#hesnotthatintoyou","query":"#hesnotthatintoyou"},
    		{"name":"Melo","query":"Melo"}]}
    ,"as_of":1256927392}
    Am I not referencing the JSON correctly or something?

    Cheers

Tags for this Thread

Posting Permissions