Yes, you do it by passing an Array object with your data in it to js,
globally(outside any function blocks), then you load it in each page. The
simplest way will be to give the page an include of a .js <script
type="text/javascript" src="MYARRAY.js"></script> or such, so the .js file
is fetched/loaded in the page, as for MYARRAY.js to get all the correct
values from the SQL query, the easiest way will be to use server side
language to do the query ONCE, and 'printf' or 'echo' or 'cat' or output
the stdout to a text file and name it MYARRAY.js or such, with the output,
for example, in PHP you'd do something like:
<?php
$setFile=fopen("MYARRAY.js","w");
fwrite($setFile,'<script type="text\/javascript"> \n\r
myArray=new Array();\n\r');
$OUTPUT_SQL_RESULTS_IN_ARRAY=SOME_METHOD_TO_RUN_TH E_QUERY_AND_OUTPUT_RESULTS();
foreach ($OUTPUT_SQL_RESULTS_IN_ARRAY as $name=>$content) {
$current="myArray[$OUTPUT_SQL_RESULTS_IN_ARRAY[$name]=$content;
\n\r";
fwrite($setFile,$current);
}
------------ ^ which is pretty much a For In loop -----------
or just use a sequential For loop
for (i=0;i<count($OUTPUT_SQL_RESULTS_IN_ARRAY);i++) {
/* then the fwrite() to the file here, pretty much
just appending the js code for it be parsed on the
client */
}
?>
Danny
On Sun, 05 Jun 2005 11:48:09 -0700, tisgrim <gw*****@blueyonder.co.uk>
wrote:
Right...have loads of C++, SQLServer experience but about 5 minutes of
JavaScript, ASP etc.
Spent a frustrating 2 days deciding the best way to get some data from
a SQL database, then cached in the browser so it could be used by a
number of pages without repeated database querying. No idea which is
the most current v obsolete technology.
Remote scripting seemed feasible but is this on the way out. Tried
implementing it but got some java file access denied issues - "access
denied (java.io.FilePermission
C:\Inetpub\wwwroot\RemoteScriptTest\rev.asp?_metho d=GetServerProxy&_mtype=execute&pcount=0
read)" that left me stumped.
My simple plan was to get a chunk of data from a database, presumably
using ASP. This would then be stored in some local array to be accessed
at leisure by client side Javascript. Am I missing the point. Is this
impossible?
Humph
--
Using Opera's revolutionary e-mail client:
http://www.opera.com/mail/