Remote Scripting Overview _ remote Scripting

Source: Internet
Author: User
"In fact, we have used this method ourselves," he said. This is commonly referred to as Remote scripting (scripting), which many people think is just a patchwork. However, this does provide a mechanism to avoid page refreshes.

Remote Scripting Overview
Basically, a remote script is a type of remote procedure call. You can interact with the server like a normal Web application, but you don't need to refresh the entire page. Like Ajax, you can call any server-side technology to receive requests, process requests, and return a meaningful result. Just as there are many choices on the server side, the client also has many options for implementing remote scripting. You can embed Flash animations, Java applets, or ActiveX components in your application, and you can even use XML-RPC, but this approach is too complex, so unless you are experienced with this technique, this approach is not appropriate. The common practice of implementing remote scripting involves combining a script with an IFRAME (hidden or not hidden), and returning JavaScript to the server, which then runs the JavaScript in the browser.
Microsoft provides its own remote scripting solution, and is intelligently referred to as Microsoft Remote scripting (Microsoft Sqlremote Scripting,msrs). In this way, you can call a server script just like a local script. The Java applet is embedded in the page to communicate with the server, the. asp page is used to place server-side scripts and the. htm file manages the layout of the client. Microsoft's solution can be used in both Netscape and IE 4.0 and later, and can be invoked synchronously or asynchronously. However, this solution requires Java, which means that additional installation routines may be required, as well as Internet Information Services (IIS), which limits server-side selection.
Brent Ashley created two free cross-platform libraries for remote scripting. JSRs is a client-side JavaScript library that leverages DHTML to make remote calls to the server. JSRs can be used on a considerable number of operating systems and browsers. If you use some of the most popular server-side implementations (such as PHP, Python, and Perl CGI), JSRs can typically be installed and run on a Web site. Ashley offers free JSRs, and can also be made from his website (www.ashleyit.com
/rs/main.htm) to get the source code.
If you think JSRs is too bulky, Ashley also creates Rslite, which uses cookies. Rslite is limited to a small amount of data and a single call, but most browsers provide support.
Examples of 2.5.2 remote scripts
For comparison, this shows you how to use an IFRAME to implement AJAX-like techniques. This is very simple, and we used to use this method in the past (before the advent of XMLHttpRequest). This example does not really call the server, just wants you to know how to implement a remote script using IFRAME.
This example includes two files: iframe.html (see Code Listing 2-2) and server.html (see Code Listing 2-3). The server.html simulates the response that should be returned from the server.
Code listings 2-2 iframe.html Files
Copy Code code as follows:

<title>example of remote scripting in a iframe</title>
<script type= "Text/javascript" >
function Handleresponse () {
Alert (' This function was called from server.html ');
}
</script>
<body>
<iframe id= "BEFOREXHR"
Name= "BEFOREXHR"
Style= "width:0px; height:0px; border:0px "
Src= "Blank.html" ></iframe>
<a href= "server.html" target= "BEFOREXHR" >call the server</a>
</body>

Code listings 2-3 server.html Files
Copy Code code as follows:

<title>the server</title>
<script type= "Text/javascript" >
Window.parent.handleResponse ();
</script>
<body>
</body>

Figure 2-2 shows the original page. The results generated by running this code are shown in Figure 2-3.

Figure 2-2 the original page

Figure 2-3 the page after the call to "server"

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.