Re: passing a variable through 2 required files embedded in Javascript

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 29 April 2005 07:08, Mark Cain wrote:
> What a mess this has turned out to be -- But perhaps you can help me.
>
> I have a dynamic site that pulls headers, navigation, and footers from text
> files.  The content for the pages is pulled from mySQL.
>
> On each page I have a JavaScript rotating banner that displays "Upcoming
> Events."  The banners rotate about every 4 seconds without the need for a
> page refresh.  The names of the individual banners themselves are fed into
> JavaScript from a PHP script that reads a folder of JPG files and makes a
> decision as to which ones to show (i.e. pass to the JavaScript).
>
> This all works and it's slick seeing that I have the difficulty of dealing
> with a server side script and a client script.  The browser calls a
> JavaScript file which has a php extension.  When the server "sees" the php
> extension the file is executed before it is delivered to the browser. 
> Since JavaScript complains about PHP functions in that file that file
> merely echo back standard JavaScript and calls another php file via
> require() that does the low level work of reading the folder and reporting
> back the JavaScript arrays.  Graphically it looks like this:
>
> 1) the Page calls the header
>      2) the header calls
>            3) a php generated JavaScript file which calls
>                     4) a php file that reads the folder on the server and
> builds the JavaScript arrays
>
>
> Now I need to add a feature and I am bumping my head on this one.
>
> How do I report the file name of the file that called the header in # 4 ? 
> In other words, I want the name of #1 to be reported in #4.  If I use
> $_SERVER["PHP_SELF"], that variable reports the name of #4.  It gets a
> little tricky because #3 is called from within a JavaScript tag.
>
> Got any suggestions?

Pass the JavaScript to the client using a new header:

Content-Type: application/x-javascript

>
> Mark Cain

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436

Attachment: pgpRddC4XLLIY.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux