Remote script files are carried by Microsoft.) (5)

Source: Internet
Author: User

Documentation: Call the Remote Scripting Method for synchronization

After configuring remote scripting on a customer page and a server page, you can call the method of this server page from your client script. By default, when a user calls a server method, it is synchronously executed-your client script can stop running until the server method is executed and the result is returned. Generally, you need to call the server method synchronously when you need the server method result in your client script.

Note that you can also call the server method asynchronously. For more information, see call the Remote Scripting method asynchronously.

When you call a server method, this method does not return a single value. Instead, create a call object that contains the returned and status information of the called process. The most common attribute is the return_value attribute of the called object, which contains a single value calculated or checked by a remote process. Other Call object attributes allow you to obtain more information about the status of Remote Procedure Calls.

If you have created an object reference for a server page, you can use the standard object. method syntax to call the method. For more information about creating object references, see reference ASP as an object. In addition, you can call the remote scripting method when no object is referenced. This method is slightly redundant than the object. method syntax, but you do not need to create object references first.

Synchronous server call Method

If you have created an object reference for the server page, you can use the first syntax example for javascript calls. For VBScript calls, you can use the second syntax example:
Javascript:
CallObject = ASPObject. methodName (p1, p2 [,...])

Vbscript:
Set callObject = ASPObject. methodName (p1, p2 [,...])

-Or-

If you have not created an object reference, call the RSExecute function. For calls using javascript, use the first syntax example. For calls using VBScript, use the second syntax example:
Javascript:
Callobject = RSExecute (url, methodName, p1, p2 [,...])

Vbscript:
Set callobject = RSExecute (url, methodName, p1, p2 [,...])

Where:

The name of the callObject to be instantiated after the remote scripting call is complete. You do not need to create this object before calling remote script.

ASPObject references to objects that can be selectively created by using the RSGetASPObject method in the early days. For more information, see reference ASP as an object.

The url contains the URL of the ASP page of the remote script you want to execute. The server page must have been configured as described in making Remote Scripting on the server page valid. The server page must be on the server from which the user requests the current customer page.

MethodName the method name on the server page you want to execute.

Any parameter required by the method in p1, p2,... methodName. Parameters are passed through values. Users can pass simple data types, such as numeric or text values, but not structured data, such as arrays or objects.
Note that when parameters are passed from the customer to the server, they are converted to strings. Make sure that your server method converts parameters to the appropriate data type. For more information, see make Remote Scripting valid on the server page.

For example, the following client script onclick handler of the btnAdd button calls the server Method add to accumulate two values. Call the remote scripting method to create a call object named co. The results of the remote scripting call are extracted from the return_value attribute of the call object and displayed as the text box value named txt3.

<Script language = "javascript" for = "btnAdd" event = "onclick">
RsMath = RSGetASPObject ("../myPages/RSMath. asp ")
Number1 = txt1.value;
Number2 = txt2.value;
Co = rsMath. Add (number1, number2 );
Txt3.value = "The sum is" + co. return_value;
</SCRIPT>

The same call (using RSExecute) generated when no object is referenced may be as follows:

<Script language = "javascript" for = "btnAdd" event = "onclick">
Number1 = txt1.value;
Number2 = txt2.value;
Co = RSExecute ("RSmath. asp", "add", number1, number2 );
Txt3.value = "The sum is" + co. return_value;
</SCRIPT>

For details about how to check errors when a remote scripting call is generated, see check errors.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.