Remote Scripting Advanced Tutorial---Make remote scripting available on server Pages

Source: Internet
Author: User
Tags constructor
In addition to configuring the customer pages to make it easier to invoke remote scripts, you must also configure your own server Pages to be available for them to receive. The practice includes the following steps:
Contains the remote scripting Server library and initializes it.
Write a function or routine that the customer page can call.
Expose your own functions and routines as methods.
By default, a client script calls an ASP page that does not appear in the browser--it simply executes on the server and sends the results to the client. Therefore, as a rule, you do not need to include any HTML text in an ASP page, but only script. However, it is possible to invoke a method that includes HTML text on an ASP page and display it normally, as long as you initialize the remote scripting Server library and expose the page's methods with the techniques described below.
Include and initialize Remote scripting Server library
Create the INCLUDE statement for the server-side reference rs.asp file, as shown in the following example:
<!--#INCLUDE file= ". /_scriptlibrary/rs. ASP "-->
Make sure that you specify the correct path for the rs.asp file. The INCLUDE statement can appear anywhere in the user's file.
Inserts a call into the RSDispatch method, which can be used to find the correct procedure when you invoke the server script from a client script. The call might look like the following:
<% RSDispatch%>
The RSDispatch call must be the first server script to run on the page. Traditionally, it is a typical practice to put it on the head of a file.
In the appropriate initialization action, create a function or routine that the user will call from the client script as a method. You can write the process in any scripting language. A procedure can accept any number of arguments, but parameters can only be strings, numbers, dates, or other simple data types--customers cannot take structured data (for example, objects or arrays) as arguments.
Note When you pass parameters from a client script to a server script, they are converted to strings. If users expect different data types in their own server methods, they can be converted within the method script.
After you have created procedures in server scripts, you must expose them as methods. To achieve this, you can create a JavaScript public description object and list the methods that users want to expose.
Revealing methods
Creates a Public_description object that specifies the constructor for your method. The following example named constructors are myservermethods:
<script language= "JavaScript" >
var public_description = new Myservermethods ();
Creates the constructor that you specified in the Public_description object. Inside the constructor, specify the name of the method that the user wants to expose, and their corresponding function or routine name. The syntax used by the user depends on whether the user is creating their own methods in JavaScript or in VBScript. You can use the following syntax:

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.