I am attempting to return an Array from a remote scripting asp. Write now the code is hard coded with data but my goal will be to load data from a record set and pass the array back to my calling page for display use. My remote page is as follows.
<!--#INCLUDE FILE="_ScriptLibrary/RS.ASP"-->
<% RSDispatch %>
<script language="JavaScript" runat="server">
var public_description = new MainMethod();
function MainMethod()
{
this.CreateArray = Function('sql','return CreateArray(sql)');
}
</script>
<script language="JavaScript" runat="server">
function CreateArray(sql) {
var OrgArray = new Array();
OrgArray[0]="1";
OrgArray[1]="1.1";
OrgArray[2]="1.1.1";
OrgArray[3]="1.1.2";
OrgArray[4]="1.1.3";
OrgArray[5]="1.1.4";
OrgArray[6]="1.2";
OrgArray[7]="1.5.1";
OrgArray[8]="1.5.2";
OrgArray[9]="1.5.3";
OrgArray[10]="1.3";
OrgArray[11]="1.4";
OrgArray[12]="1.5";
OrgArray[13]="2";
OrgArray[14]="2.1";
OrgArray[15]="2.1.1";
OrgArray[16]="2.1.2";
OrgArray[17]="2.1.3";
OrgArray[18]="2.2";
OrgArray[19]="2.3";
OrgArray[20]="2.4";
return OrgArray;
}
</script>
My calling page has the following code:
<script language="JavaScript" src="_ScriptLibrary/RS.HTM">
</script>
<script language="JavaScript">
RSEnableRemoteScripting("_ScriptLibrary"
</script>
<script language="JavaScript">
var sql="";
var objRS = RSGetASPObject("RSArray.asp"
var objResult = objRS.CreateArray(sql);
alert(objResult[0]);
</script>
I get undefined from the alert.
<!--#INCLUDE FILE="_ScriptLibrary/RS.ASP"-->
<% RSDispatch %>
<script language="JavaScript" runat="server">
var public_description = new MainMethod();
function MainMethod()
{
this.CreateArray = Function('sql','return CreateArray(sql)');
}
</script>
<script language="JavaScript" runat="server">
function CreateArray(sql) {
var OrgArray = new Array();
OrgArray[0]="1";
OrgArray[1]="1.1";
OrgArray[2]="1.1.1";
OrgArray[3]="1.1.2";
OrgArray[4]="1.1.3";
OrgArray[5]="1.1.4";
OrgArray[6]="1.2";
OrgArray[7]="1.5.1";
OrgArray[8]="1.5.2";
OrgArray[9]="1.5.3";
OrgArray[10]="1.3";
OrgArray[11]="1.4";
OrgArray[12]="1.5";
OrgArray[13]="2";
OrgArray[14]="2.1";
OrgArray[15]="2.1.1";
OrgArray[16]="2.1.2";
OrgArray[17]="2.1.3";
OrgArray[18]="2.2";
OrgArray[19]="2.3";
OrgArray[20]="2.4";
return OrgArray;
}
</script>
My calling page has the following code:
<script language="JavaScript" src="_ScriptLibrary/RS.HTM">
</script>
<script language="JavaScript">
RSEnableRemoteScripting("_ScriptLibrary"
</script>
<script language="JavaScript">
var sql="";
var objRS = RSGetASPObject("RSArray.asp"
var objResult = objRS.CreateArray(sql);
alert(objResult[0]);
</script>
I get undefined from the alert.