Results 1 to 3 of 3
  1. mfive's Avatar
    Posts
    186 Posts
    Global Posts
    193 Global Posts
       #1  
    Hey gang,

    I'm trying to get this f'ing Ajax.Request to work and I'm baffled as to why it's not working...

    I've used Ajax.Request in other places in my previous apps but I can't get it to work for some reason here.

    I can't post my entire source code for this project, as it's going into the official app catalog (I hope), but I was hoping you guys can help still. Here's my code, very simple, it's not even doing anything with the data yet!

    Mojo.Log.info("Getting Data");
    var url = "http://mylinkhere.com/?test=test";
    Mojo.Log.info("Complete URL is: ", url);

    var request = new Ajax.Request(url,
    {
    method: "get",
    evalJSON: "false",
    onSuccess: function(transport) { Mojo.Log.info("Great Success!"); },
    onFailure: function(transport) { Mojo.Log.info("Failure!"); }
    });

    The above code doesn't execute either a success or failure log. It doesn't seem to do much of anything, and it continues right onto the next block of code which executes fine... It seems that my syntax is all right, and if I test my url that I use in the app, I get back the response just fine. (All it does is return one word...).
  2. kesne's Avatar
    Posts
    471 Posts
    Global Posts
    491 Global Posts
    #2  
    This should do the trick. Don't set the get's through the URL, use the Ajax.request parameters. If you need anymore help, feel free to ask.

    Code:
    Mojo.Log.info("Getting Data");
    var glUrl = "http://my-url.net/getinfo.php";
    new Ajax.Request(glUrl, {
        method: 'get',
    	parameters: {test: this.test},
        onComplete: function(){},
        onSuccess: function (transport) {Mojo.Log.info("Das ist gut!"); },
        onFailure: function (failure) {Mojo.Log.info("Nicht so gut!"); }
    });
  3. mfive's Avatar
    Posts
    186 Posts
    Global Posts
    193 Global Posts
       #3  
    Executes perfectly, hopefully this post will help someone else too!

Posting Permissions