Displaying Source Code(s)
|
|
Remote Scripting Basics
--------------------------------------------------------------------------------
Description : Remote Scripting is a magical, infinitely powerful
Javascript client library that allows: Javascript in an HTML or
ASP page to call an ASP subroutine on the server to fetch data
dynamic page construction via Javascript that could be for
example fetching database data for a page without reloading the
page. The main limitations are the browser must be a 4.x browser
It doesn't work on IE Mac (thanks to "Brad Rhoads" for that tip)
The current version requires 3 files: rs.asp, rs.htm and
rsprox.class which can be downloaded from http://msdn.microsoft.com/scripting
on the server to work and their exact path must be set in the
files (/learn/test/remote/ is the path in these samples).
Our sample remote1.htm looks like this:
<HTML><HEAD><TITLE>remote1.htm</TITLE></HEAD>
<BODY onload="handleRSExecute()">
<script language="JavaScript" src="/learn/test/remote/rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("/learn/test/remote/");</script>
<h2>Simple Remote Scripting Example</h2>
<form name="remote1">
The Test <Input Type="text" name="test" value="none">
<SCRIPT LANGUAGE="javascript">
var serverURL = "remote1.asp";
Function myCallBack(co)
{
// document.write (co.return_value);
remote1.test.value=co.return_value;
}
Function handleRSExecute()
{
var co = RSExecute(serverURL,"Method3");
myCallBack(co);
}
</SCRIPT>
</form>
</HTML>
Our sample remote1.asp looks like this:
<%@ LANGUAGE=VBSCRIPT %>
<% RSDispatch %>
<!--#INCLUDE VIRTUAL="/learn/test/remote/rs.asp"-->
<SCRIPT RUNAT=SERVER Language=javascript>
Function Description()
{
this.Method1 = Method1;
this.Method2 = Method2;
this.Method3 = Method3;
}
public_description = New Description();
Function Method1()
{
return "method1";
}
Function Method2()
{
return "method2";
}
Function Method3()
{
return "method3";
}
</script> |
|
|