470,616 Members | 2,300 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,616 developers. It's quick & easy.

Include file

I'm having the folowing problem:

I'm getting an Array from an external source, the data in the array depents
on the get variables.
These get variables should be decided by the browser, after there decided I
can created the adres to get the file with the JavaScript Array.
How do I include this file???

Basicaly what I want in the script is something like:
include(http://the.source.com/javascript/arr...tart=a&end=g);
Jul 20 '05 #1
5 1405
John Smith wrote:
I'm getting an Array from an external source, the data in the array
depents on the get variables.
These get variables should be decided by the browser, after there
decided I can created the adres to get the file with the JavaScript
Array.
How do I include this file???

Basicaly what I want in the script is something like:
include(http://the.source.com/javascript/arr...tart=a&end=g);


Does array.php produce valid js code? Then it's sufficient to include the
file as follows:

<script type="text/javascript"
src="http://the.source.com/javascript/array.php?start=a&end=g"></script>

And then access the defined variables as you would when they where local.
JW


Jul 20 '05 #2
Yes, it produce valid js code,
but the problem is that another script decides the values of a and g
array.php?start=a&end=g

"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:40***********************@news.wanadoo.nl...
John Smith wrote:
I'm getting an Array from an external source, the data in the array
depents on the get variables.
These get variables should be decided by the browser, after there
decided I can created the adres to get the file with the JavaScript
Array.
How do I include this file???

Basicaly what I want in the script is something like:
include(http://the.source.com/javascript/arr...tart=a&end=g);


Does array.php produce valid js code? Then it's sufficient to include the
file as follows:

<script type="text/javascript"
src="http://the.source.com/javascript/array.php?start=a&end=g"></script>

And then access the defined variables as you would when they where local.
JW

Jul 20 '05 #3
John Smith wrote:
Yes, it produce valid js code,
but the problem is that another script decides the values of a and g
array.php?start=a&end=g


The you can write the tag dynamically:

var start = 'something';
var end = 'something';

document.write(
'<script type="text/javascript" ',
'src="http://the.source.com/javascript/array.php',
'?start=', start, '&end=', end, '">',
'<\/script>'
);
JW

Jul 20 '05 #4
I will try this but wont this give a timing problem???

"Janwillem Borleffs" <jw@jwscripts.com> schreef in bericht
news:40***********************@news.wanadoo.nl...
John Smith wrote:
Yes, it produce valid js code,
but the problem is that another script decides the values of a and g
array.php?start=a&end=g


The you can write the tag dynamically:

var start = 'something';
var end = 'something';

document.write(
'<script type="text/javascript" ',
'src="http://the.source.com/javascript/array.php',
'?start=', start, '&end=', end, '">',
'<\/script>'
);
JW

Jul 20 '05 #5
John Smith wrote:
I will try this but wont this give a timing problem???


No, unless you use the defer attribute in the script tag, the browser will
wait for the remote file to finish loading before it continues parsing the
page.
JW

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by wukexin | last post: by
28 posts views Thread by Ramesh | last post: by
60 posts views Thread by Derrick Coetzee | last post: by
9 posts views Thread by bill | last post: by
12 posts views Thread by Francois Grieu | last post: by
9 posts views Thread by zolli | last post: by
5 posts views Thread by David Mathog | last post: by
6 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.