Jump to content

getting value from serverside page using script src


bipin

Recommended Posts

i need to display the content from serverside page but using script tag

i tried to do script tag as below

<script src="test.php">

 

but it generates the dom error

ony i can see the value while i view the source code of the page not in the web page

so any help n suggestion is most welcomed

why not do this instead?

<script>
<?php
echo("your javascript");
?>
</script>

or

<script>

<?php

include("test.php");

?>

</script>

 

external files stay in the browser cache... so you dont need to redownload them for every load of the pages... its best to keep (most) js functions in an external, and only initiate it in the parent window :)

 

as for having a php document acting as a js document... in your .htaccess... add in

"AddType application/x-httpd-php .js"

which'd tell the server to parse your <script src="file.php"> file before acting it as a js file :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.