Results 1 to 4 of 4
  1.    #1  
    I've been trying to debug my first AJAX request from the Pre all day. I'm trying to connect to one of my own servers. I have a spinner on the button that kicks of the request that should stop with either callback (as well as a dialog, success or fail). However, the spinner continues and neither dialog pops up. Here is an example of my AJAX request code...

    Code:
    // SET AJAX URL VARIABLE
    
    	var myRequestURL = 'http://www.mywebsite.com/page.php';
    
    // CREATE HASH OF VALUES TO PASS TO WEB SERVER
    
    	var myRequestParameters = new Hash();
    	myRequestParameters.set('name1', this.variable1);
    	myRequestParameters.set('name2', this.variable3);
    	myRequestParameters.set('name3', this.variable3);
    
    // SET AJAX ATTRIBUTES
    
    	var myRequestAttributes =
    	{
    		    method: 'post',
    		  evalJSON: 'true',
    		parameters: myRequestParameters,
    		 onSuccess: this.myRequestSuccess.bind(this),
    		 onFailure: this.myRequestError.bind(this)
    	};
    
    // MAKE AJAX REQUEST
    
    	var myRequest = new Ajax.Request(myRequestURL, myRequestAttributes);
    Here is my callback code...

    Code:
    this.myRequestSuccess = fuNction(response)
    {
    	Mojo.Controller.errorDialog('AJAX Worked!');
    	createAccount.mojo.deactivate();
    }
    
    this.myRequestError = fuNction(response)
    {
    	Mojo.Controller.errorDialog('Account creation failed, please try again!');
    	createAccount.mojo.deactivate();
    }
    Please help!!! I need a fresh pair of eyes...
    Last edited by Laxidasical; 10/24/2009 at 12:49 AM. Reason: Typo
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  2. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #2  
    This line is wrong
    var myRequest = new Ajax.Request(myRequestURL, var myRequestAttributes);

    remove "var", it isn't needed and might screw things over
    Apps: MyQ for Netflix (Phone/TouchPad), Giantbomb (Phone), Excavate (Reddit/Digg clients for TouchPad)
  3.    #3  
    Sorry, that was a typo in my example! It's not in my original code. Other than that, do you see anything else?
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  4. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #4  
    put a try {your ajax code} catch (e){Mojo.Controller.errorDialog(e);} and see if an exception is occuring
    Apps: MyQ for Netflix (Phone/TouchPad), Giantbomb (Phone), Excavate (Reddit/Digg clients for TouchPad)

Posting Permissions