Include file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Smith

    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);


  • Janwillem Borleffs

    #2
    Re: Include file

    John Smith wrote:[color=blue]
    > 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);[/color]

    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




    Comment

    • John Smith

      #3
      Re: Include file

      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.c om> schreef in bericht
      news:4024e4a1$0 $89923$1b2cd167 @news.wanadoo.n l...[color=blue]
      > John Smith wrote:[color=green]
      > > 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);[/color]
      >
      > 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
      >
      >
      >
      >[/color]


      Comment

      • Janwillem Borleffs

        #4
        Re: Include file

        John Smith wrote:[color=blue]
        > 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
        >[/color]

        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



        Comment

        • John Smith

          #5
          Re: Include file

          I will try this but wont this give a timing problem???

          "Janwillem Borleffs" <jw@jwscripts.c om> schreef in bericht
          news:4024e847$0 $89916$1b2cd167 @news.wanadoo.n l...[color=blue]
          > John Smith wrote:[color=green]
          > > 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
          > >[/color]
          >
          > 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
          >
          >
          >[/color]


          Comment

          • Janwillem Borleffs

            #6
            Re: Include file

            John Smith wrote:[color=blue]
            > I will try this but wont this give a timing problem???
            >[/color]

            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



            Comment

            Working...