Menu

#6 Add parameters to callback functions

open
3
2007-06-07
2007-06-07
Jim Plush
No

Discussion

  • brazilnut

    brazilnut - 2007-06-15

    Logged In: YES
    user_id=690970
    Originator: NO

    I don't know where you're at with this, but just a quick thought on it. Would this be easier to implement by passing in an array rather than an unknown amount of parameters?

    e.g.

    ajaxObj.call("action=xyz", callbackFunction, array("abc", 123, "xyz"));

    function callbackFunction(resp, arg1, arg2, arg3)
    {
    alert(arg1); // would alert "abc"
    alert(arg2); // would alert 123
    alert(arg3); // would alert "xyz"
    }

     
  • Jim Plush

    Jim Plush - 2007-06-15

    Logged In: YES
    user_id=1491998
    Originator: YES

    I was thinking more along the lines of an object literal or an object so you can have named parameters.

    var callback = {function: callbackFunction,
    param1:"test"};

    ajaxObj.call("action=xyz", callback);

     
  • brazilnut

    brazilnut - 2007-06-15

    Logged In: YES
    user_id=690970
    Originator: NO

    Makes sense.

    Would there be the possibility of adding an interface on the PHP side to specify which of the named variables are passed to the callback?

     

Log in to post a comment.

MongoDB Logo MongoDB