Click to See Complete Forum and Search --> : ASP --> JScript Array.push() method - (Resolved)


Brad Jones
September 11th, 2003, 04:03 PM
A piece of ASP code written primarily in JScript is being moved from one server to a new one with idenitical set ups. On the new server, the JScript code is giving an error. The push method is not being recognized as a valid method of the Array object. The chunk of code that is giving an error is:




// This section is used to get all categories dynamically.
var docHeadlines =
objXMLDoc.documentElement.selectNodes("book/CategoryList/cat");
var numNodes,nn;
var aTypes = new Array();
aTypes.push(new Array("--All--",0,""));
numNodes=docHeadlines.length;
var Check=0;

for(var i=0;i<numNodes;i++)
{
nn = docHeadlines.nextNode();
Check = 0;

for(var j=0;j<aTypes.length;j++)
{
if(aTypes[j][0]==nn.text)
{
Check=1;
break;
}
}

if(Check==0)
aTypes.push(new Array (nn.text,aTypes.length,nn.text));
}
// End of Section


The two red lines are the ones giving errors. Any thoughts?

Brad!

Brad Jones
September 11th, 2003, 05:09 PM
Problem solved.

JScript 5.1 doesn't support Array.push. This support started around JScript 5.5.

The servers that this program was placed on were not identically set up. Rather, the new server had an older version of the JScript runtime.

Lesson learned :D.

Brad!