Montag, Juli 18, 2005

More Options for AJAX Actions

Since the first publication I have implemented some changes and additions in the AJAX engine and the framework for WebServices.

ajax.Start(action1, option)

prepare(option) / finish(data, option), onExeption(ex, option)

When starting an AJAX action the only options that could be specified where those that are part of the JavaScript object describing the action. These options are the same for all executions of this action. With this addition it is now possible to define an option for a specific execution.

The ajax.Start Method now has a second parameter. This value is stored into the queue of the AJAX engine together with the fist parameter specifying the action.

When the prepare and finish methods are executed as well on handling en exception, this value is passed as an additional parameter. By using this value it is possible to store a context of an action. That may be for example a HTML object that started the action. Because all methods have access to it, it is now possible to use the same action definition for multiple fields, forms or other situations. Without this parameter it was necessary to implement the direct access to the HTML objects inside the prepare and finish methods.


Calling this method will close the actual connection to the saver by calling the abort method of the xmlhttp object before the result is returned from the server.

This is only possible on asynchronous calls.


This method makes it easy to watch the communication of the return value of a server call. But the situation is similar to the Heisenberg uncertainty principle: If you watch the package you cannot see the effect anymore because the data from the server is shown to the user but is not passed to the finish method. Also the timing situation is ruined because an alert box is used.

This option can be activated by assigning the alertResult method to the otherwise internally used corefunc property.

proxies.service.method.corefunc = proxies.alertResult;

Even if it breaks, it was necessary from time to time to see the result of a call so this option remains in the client-side WebService framework.


It is not well known that the Microsoft Internet Explorer (IE) allows to copy the content of an alert box into the clipboard by using Ctrl+C.


This method cancels the execution of the currently running action. If a timeout value is specified in the action options this method is called automatically.


This method cancels the execution of the currently running and all the pending actions.

1 Kommentar:

Dan F hat gesagt…

that second parameter sounds pretty sweet.