SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot ThetaWaveRider's Avatar
    Join Date
    Aug 2004
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax.Request return value

    Hey all,

    Anyone know how to return true or false to an event handler based upon the results that come back from a Prototype Ajax.Request call?

    I have a link with an onclick handler that calls a function getLoggedIn(), which looks like the following:

    Code:
    function getLoggedIn(type) {
      ajax = new Ajax.Request(
        'includes/checkloggedin.php', 
        {
          method: 'get',
          parameters:'&type='+type,
          onComplete: checkLoginResult
        });
    }
    As any analysis of request.responseText occurs in checkLoginResult(), not getLoggedIn(), how can I pass an Ajax-response-determined return value back to the event handler?

    Thanks,
    TWR
    Last edited by ThetaWaveRider; Jul 26, 2007 at 12:16.

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need a synchronous call instead of an asynchronous one. Check out the latest Sitepoint article on Javascript.

  3. #3
    SitePoint Zealot ThetaWaveRider's Avatar
    Join Date
    Aug 2004
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, talk about a recent article - my question couldn't have been timed better. I'll check it out, thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •