SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot bloo_fish's Avatar
    Join Date
    Aug 2003
    Location
    Bucks [Uk]
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Java script object problem - hopefully simple!

    Hi,


    I am currently using the YUI JS library for AJAX. I have the follwoing code

    Code:
          // ajax callback object
          oCallback = {
             success : myFunctionHere,
             failure : null,
             argument : null
          };
          
          // Run ajax request
          var oConnect = YAHOO.util.Connect.asyncRequest('GET', '/includes/quotes.php?' + sQueryString, oCallback);

    But where it says 'success : myFunctionHere,' i want that to read the function name from a variable - now as its not quoted and this is the name of the function in plain text i am slightly baffled!


    Can anybody shine some light on how this working / what i need to do?



    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    does this do it for ya?
    Code:
    function something() {
    // stuff
    }
    ...
    var pleaseCall = "something";
    oCallback = {
       success : window[pleaseCall],
       failure : null,
       argument : null
    };

  3. #3
    SitePoint Zealot bloo_fish's Avatar
    Join Date
    Aug 2003
    Location
    Bucks [Uk]
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jimfraser View Post
    does this do it for ya?
    Code:
    function something() {
    // stuff
    }
    ...
    var pleaseCall = "something";
    oCallback = {
       success : window[pleaseCall],
       failure : null,
       argument : null
    };

    Perfect! thank you.


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
  •