By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

cacheing (is that a word) remote data in browser

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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/
Jul 23 '05 #2

P: n/a
VK
If SQL data must be unique for each user session, then you have three
options to choose from:

1. Set session cookie. It holds up to 1Kb guaranteed. So unless you
have some MEMO fields like Full_Story_Of_My_Life, it should be fair
enough for anything.

2. Use the shame of frames (pls don't)

3. Create server-side session .js files and then
<script src="id0u3u4ud9g7j4.js"></script>
It raises the questions though 1) of server clean up after and 2)
possible privacy exposure via cache (fixable but extra headache).

Tell me what you like the most.

Jul 23 '05 #3

P: n/a
wl
"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
If SQL data must be unique for each user session, then you have three
options to choose from:

1. Set session cookie. It holds up to 1Kb guaranteed. So unless you
have some MEMO fields like Full_Story_Of_My_Life, it should be fair
enough for anything.

2. Use the shame of frames (pls don't)

3. Create server-side session .js files and then
<script src="id0u3u4ud9g7j4.js"></script>
It raises the questions though 1) of server clean up after and 2)
possible privacy exposure via cache (fixable but extra headache).

Tell me what you like the most.


As a remark on option 3: instead of using "<script src="....js">" you
can also refer to a serverside URL (ASP, ASP.NET, JSP, ...) that return
the

JavaScript code. No problem on cleaning up the .js file afterwards then.

Wim
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.