SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict JamieJelly's Avatar
    Join Date
    Jan 2004
    Location
    London
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    method not being passed ajax request results

    I wrote a small script which was a bit messy, a simple autocomplete thing. I decided to rewrite it as a javascript object, but now the results from my ajax call are not being passed to the handler method... I can't work out why. This is a brief overview of what I have now:
    Code:
    var aC = {
    addEvent: function() {...},
    init: function() {
    	aC.search = document.getElementById('search');
    		
    	aC.addEvent(aC.search, 'keyup', aC.doLookup, false);
    },
    
    doLookup: function() {
    	var qs = '?search=' + aC.search.value;
    	var xmlhttp = new Ajax();
    	xmlhttp.doGet('check.php' + qs, aC.handleLookup);
    },
    
    handleLookup: function(str) {
            alert(str.value);
    },
    
    search: '';
    };
    
    aC.addEvent(window, 'load', aC.init, false);
    Previously, when all of this was outside a function it worked fine... can anyone shead any light on this for me?

    thanks
    International calls from the UK
    Cheap International Calls

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The obvious question is: does addEvent work? What does it look like? What do doGet and Ajax look like?

    Need more info
    Hello World


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
  •