Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.