Pre[loading|setting] a data feed?

L

lbrtchx

~
I need to preload a data file to feed some js code belonging to a
page, before the page opens in a crossbrowser way
~
And I need to use the same path, say, "js/data/customdata(.js?)",
inside the js code
~
I am attempting not to change the js code for each user just because
the data feed changes
~
I know how to set the content of the data based on users' login info
and previous configurations, even though the same path to the data
file is used (that part I do with server side code)
~
Also, do you know of any example of how to dynamically do this
without users having to login and/or doing a full reload of the page?
~
Thanks
lbrtchx
 
S

SAM

Le 12/6/08 12:50 PM, (e-mail address removed) a écrit :
~
I need to preload a data file to feed some js code belonging to a
page, before the page opens in a crossbrowser way
~
And I need to use the same path, say, "js/data/customdata(.js?)",
inside the js code
~
I am attempting not to change the js code for each user just because
the data feed changes
~
I know how to set the content of the data based on users' login info
and previous configurations, even though the same path to the data
file is used (that part I do with server side code)
~
Also, do you know of any example of how to dynamically do this
without users having to login and/or doing a full reload of the page?


If the page isn't reloaded (that's to say loaded) how can you speak of
*pre*loading ?

Without reloading it becomes *post*loading ;-)

Now, what is the question ?

Isn't it an Ajax feature what you try to get ?
<http://www.jibbering.com/faq/#ajaxRef>

Without Ajax you can try something as following which consists to have a
function to set what you want with the datas, and another function to
postload (reload) the JS file of this datas (I can no more reach (call?)
the file testing the different way to postload JS script as the web-site
(personal pages on AOL) seems to be closed, so it's possible this
postload function can abort with some browsers)


<script type="text/javascript" src="datas.js"></script>
<script type="text/javascript">
// all the job to do with the datas
funtion init() {
if(data) with (data) {
// blah
}
}
init();

function postload() {
var s = document.createElement('SCRIPT');
s.type = 'text/javascript';
s.src = 'datas.js';
document.getElementsByTagName('HEAD')[0].appendChild(s);
init();
return false;
}
</script>
</head>
<body>
<p><a href="<?php echo $_SERVER['PHP_SELF'].'?'.rand() ?>"
onclick="return postload(this)">refresh</a>
 
L

lbrtchx

If the page isn't reloaded (that's to say loaded) how can you speak of
*pre*loading ?

Without reloading it becomes *post*loading ;-)
~
Well, I wasn't clear enough, but based on the context anyone could
have guessed I meant to actually load some file with data prior to
running some script which is fed by that data
~
lbrtchx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top