Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Error in reading text file


Message #1 by "Ramez" <rchehab@s...> on Tue, 29 Oct 2002 20:44:07
Hi,

I have the following .asp file in an iis server and another .js file that 
resides in the same directory in the server. The problem is that I get the 
following error code, no matter what I've been trying for a week now, 
while trying to read the usersFile.js file as repeated below.

-----
Microsoft JScript runtime error '800a1391'

'usersList' is undefined

/checkLogin .asp, line 32 - The first "Response.Write" statement in the 
function.
-----

First, here is the code for the checkLogin.asp file.

<%@ language = "JavaScript" %>

<%
       function readUsersFromArray()
       {
              Response.Write(usersList[0][0]);
              Response.Write(usersList[0][1]);
              Response.Write(usersList[0][2]);
       }
%>

Here is the usersFile.js file that contains a simple array as defined now:

----------
      var usersList = new Array();
      usersList = new Array();

      usersList[0][0] = "Statement1"
      usersList[0][1] = "Statement2"
      usersList[0][2] = "Statement3"
----------

I've used the #include directive from within the function before the 
first "Response.Write" statement in oreder to include the usersFile.js 
file, it didn't work.

Then I've introduced the #include directive before the call to the 
function, again the same message except for the line number that have 
changed of course.

I tried to include this :
<script language="JavaScript1.1" src="usersFile.js"></script> with no 
success.

The program works if I write the array in the .asp file but is unknown 
when included. I've tried to include like this :

//#include file="usersFile.js" --> Nothing.

or :

//#include file="d:\usersFile.js", where d:\ is the servers drive; again 
nothing with or without space between the // and # signs.

The whole thing works fine in client JavaScript by replacing the 
Response.Write statements with alerts statements; but not with Server Side 
Scripting.

It looks as it just doesn't include the .js file, and I can't see myself 
anymore why? Unless, there's a special way that I'm not aware of since I'm 
new to ASP. Can you help me please????

Regards

Ramez

  Return to Index