Re: onComplete: handleSuccess - What gets passed?

Eric Anderson
Sat, 05 Aug 2006 17:43:49 -0000

Alex Duffield wrote:
> Eric, thanks for the answer. I was hoping to be able to get the options
> (parameters in particular)  that where used in the origian request. Oh
> well. Ill find another solution.

Hmmmm.... I guess I was not very clear. The following statement was the
primary answer to your question:

I wrote:
>> Finally, all event handlers for the Ajax.Request object are executed
>> in the context of the Ajax.Request object. That means that the
"this"
>> identifier can be used to query the Ajax.Request object that made the
>> request.

Since your callbacks are executed in the context of the Ajax.Request
object you can access the Ajax.Request object with the "this"
identifier. The Ajax.Request object of course stores all your options
(plus various other info). So if you want the parameters you can do:

function mySuccess(transport, json) {
	alert(''Ajax request with parameters '' +
		this.options.parameters + '' finished executing'');
}
new Ajax.Request(url, {onSuccess: mySuccess});

Eric