I apologize if this is something really basic and obvious I am missing but I am practically tearing my hair out over this. This site metroguardian.net has a script call that uses this url as the source: www.metroguardian.net/shop/cart.php?target=special_offer&action=show_box (so in other words, it works when I do this: <script src="http://www.metroguardian.net/shop/cart.php?target=special_offer&action=show_box"></script> ) and that url appears to be regular HTML. I am trying to do something similar where a PHP script will generate a dynamic piece of HTML and then I can include it in a static page by calling it like this <script src="http://www.mysite.com/example.php?generate"></script> but it just doesn't work. What is metroguardian.net doing that they are able to serve that page up as a script?
you can even use a .exe file to as script src, however the outputs have to be only js without script tags, lets say i got <script src='file.php'></script> and i wanted to write the IP addres using js, the content of file.php should be <?php echo 'document.write("'.$_SERVER['REMOTE_ADDR'].'")'; ?> PHP: actually just the same as when using a .js file -Godkillah
Include this line as the first line after <?php Header("content-type: application/x-javascript"); That will tell the Browser to output the PHP script results as a JAVA. Your output will need to use the document.write method..., and there should be only one call. So, gather up everything before displaying. EX: // display output echo "document.write(\"". addslashes($my_output) . "\")"; ...hope that helps.
@webray: although application/javascript is the correct mime type IE doesn't seem to support it. @OP: What did you try? Do you have any code?