Remote Script document (reprinted from Microsoft) < six > asynchronous invoke remote Scripti
Source: Internet
Author: User
Documents: Calling Remote Scripting method asynchronous
Remote scripting gives you the option to asynchronously invoke the server method--The user's client script continues to run when the server method is executed. Calling the remote scripting Method asynchronously allows you to avoid slowing down the application user interface because you can continue to work while the server script is executing.
Note If your application requires it, you can also call the server method synchronously. For more information, see synchronizing calls to the Remote scripting method.
Calling a remote script asynchronously is similar to a synchronous call. However, when a call is generated, you specify up to three additional parameters:
When the server method completes processing, there is a called JavaScript callback function in the user's client script. For example, if a user's remote scripting method performs a database check, the callback function may get the check value returned by a remote call and appear in a control on the page.
An optional JavaScript error callback function--called if an error is encountered during an asynchronous call.
An optional context parameter. This is the data that the user passes to the method and returns the user at a later time. It is typically used to help you decide what method is being called in your own callback function, for example, if you are passing all remote script calls back to a callback function.
Similar to a synchronous call, an asynchronous call creates a calling object that supports properties that contain the return value and state information of the invoked procedure. For example, the return value of a remote scripting method can be obtained in the Return_value property of the calling object. When called asynchronously, the object Status property is invoked to provide the user with information about the state of the call.
When you produce an asynchronous call, the calling object is passed as a parameter to the callback function. This allows you to test it in the calling script (for example, to determine the status of the call), or to test in the callback function (for example, get the return value of the method).
If you have created an object reference to a server page, you can invoke the method with the standard Object.Method syntax. For more information about creating object references, see referencing ASP pages as objects.
How to invoke the server method asynchronously
If the user has created an object reference to the server page, you can use the following syntax. Because you must pass the function pointer of the callback function, you must use JavaScript for asynchronous method calls.
CallObject = Aspobject. MethodName (P1, p2[,...],
Callbackfunction, errorcallbackfunction, context)
Or
If you have not yet created an object reference, you can call the Rsexecute function with the following syntax:
CallObject = Rsexecute (URL, methodname, p1, p2[,...],
Callbackfunction, errorcallbackfunction, context)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.