As I surmised, I needed to make use of closures to get this right. For the
record you'd have to do something similar in jQuery as well, although we are
using roll-your-own code (not sure why we're doing that).
Eric
On 5/17/07, Christopher Jordan <[EMAIL PROTECTED]> wrote:
See? I told ya. Dumb question. Glad you worked it out, and thanks for
sharing the solution! :o)
Chris
Christopher Jordan wrote:
Eric,
What do you get if you alert(formalParameter) inside of blahCallback?
I'm used to using a library like jQuery or AjaxCFC (not really a library,
I know), where this sort of thing is generally taken care of for me, so it
may be a dumb question.
Chris
Eric Knipp wrote:
I am still a bit of a n00b when it comes to advanced AJAX programming, and
I am running into a problem that I'm having a hard time figuring out. I've
already done a number of Googles to try and find a good solution, and I
think I need to do something with closures (another concept I don't know
that well - yet), but I am not sure how to bring this off.
Basically, I have an asynchronous XMLHTTPRequest, and when it completes I
have a callback function. The callback function needs access to a parameter
that is available only to the function that invoked the XMLHTTPRequest. The
only thing that comes back from the XMLHTTPRequest object is a status, and
that doesn't help me with what I am trying to do (although trapping that for
error handling is useful but outside of the scope of my question). Here is
some code:
blah: function(formalParameter)
{
// assume asyncInvoker is handling the XMLHTTPRequest details.
asyncInvoker('get', 'myurl.cfm?parameter=' + formalParameter,
blahCallback);
}
blahCallback: function(formalParameter)
{
// this is where I need to be able to get to formalParameter, but I am
not sure how.
doSomething(formalParameter);
}
Sorry that this is OT but I figure by now there is a lot of AJAX around...
Eric
------------------------------
_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.instantspot.com/
www.teksystems.com/
-- http://www.cjordan.us
-- http://www.cjordan.us
_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.instantspot.com/
www.teksystems.com/
_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.instantspot.com/
www.teksystems.com/