|
Remote Scripting Basics by Charles Carroll
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 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:
filename=/learn/test/remote1.htm
<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"><br>
<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:
filename=/learn/test/remote1.asp
<%@ 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>
|