Welcome Guest, Not a member yet? Register   Sign In
Passing variables model to javascript
#4

[eluser]Nick Husher[/eluser]
Prototype's callback for when the Ajax function is complete is (IIRC) onComplete. If you have nothing tied to that event, you'll never know when the remote server request is completed. Try:
Code:
function callAmazon(artist, album)
{    
    new Ajax.Updater('coverContainer', 'http://localhost:8888/honours/index.php/music/amazon/artist/album', {
        method: 'get',
        onLoading:  function() { $('coverContainer').inner*HTML='Loading ...'; },
        onComplete: function() { $('coverContainer').inner*HTML='Load complete. Whee!';}
    });
}
(remove the asterisks that I inserted to prevent the forum software from censoring me)

Also, wouldn't you kinda want to request a specific album? When you get around to returning album covers, I think you'd want to do something like this:
Code:
function callAmazon(artist, album)
{    
    var requestURL = 'http://localhost:8888/honours/index.php/music/amazon/'+artist+'/'+album;

    new Ajax.Updater('coverContainer', requestURL, {
        method: 'get',
        onLoading:  function() { $('coverContainer').inner*HTML='Loading ...'; },
        onComplete: function(response) {
            $('coverContainer').inner*HTML='Response: '+response.responseText;
        }
    });
}

Note that I added dynamically changing 'artist' and 'album' fields in the URL string and inserted a reference to the response object that Prototype hands to event listeners when onComplete is fired. The response object is documented on this page.


Messages In This Thread
Passing variables model to javascript - by El Forum - 01-30-2008, 08:27 AM
Passing variables model to javascript - by El Forum - 01-30-2008, 08:47 AM
Passing variables model to javascript - by El Forum - 01-30-2008, 08:53 AM
Passing variables model to javascript - by El Forum - 01-30-2008, 09:01 AM
Passing variables model to javascript - by El Forum - 01-30-2008, 10:03 AM
Passing variables model to javascript - by El Forum - 01-30-2008, 12:47 PM
Passing variables model to javascript - by El Forum - 01-30-2008, 01:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB