pneudralics Posted December 24, 2009 Share Posted December 24, 2009 I wasn't sure where to put this thread. I'm trying to get a javascript src to display a php page. The problem is when I use php on the page like test2.php below it doesn't display anything. If I use plain text it works. What can I do to let it display php echos? test.php <script type="text/javascript" src="http://localhost/test.php"></script> test2.php //The below works var test = ''; test = "<div style=\"color:#FF0000;\">yay</div>"; document.write(test); //The below does not work var test = ''; test = "<div style=\"color:#FF0000;\"><?php echo 'blahblah'; ?></div>"; document.write(test); Link to comment https://forums.phpfreaks.com/topic/186204-php-java-script-src/ Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 Try placing.... <?php header("content-type: text/javascript"); ?> in the top of the js/php page. Link to comment https://forums.phpfreaks.com/topic/186204-php-java-script-src/#findComment-983383 Share on other sites More sharing options...
pneudralics Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks worked perfect. Link to comment https://forums.phpfreaks.com/topic/186204-php-java-script-src/#findComment-983384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.