Forum Moderators: open
I need help with the following problem.
I would like users to be able to call on a php script through a javascript command like so:
<script language="javascript" src="http://file.php"></script>
But it does not work ie. nothing shows on the screen.
Is the above command correct?
How do I need to alter my php file in order to show on the users'onw website? Much previous reading points to using document.wite()... but how, where?
Thank you for your help.
Here is what I have done:
index.php
<script type="text/javascript" src="http://...../hello.php"> </script>
hello.php
<? echo"document.write('remote hello');";?>
When I execute hello.php I get: document.write('remote hello');
But when I execute index.php, I get nothing! I guess I am expecting that src="http://roberto.speich.free.fr/NeoCOUNTER/hello.php"> be replaced by document.write('remote hello');
What do you think I am doing wrong?
You are trying to execute a server-side script on the client.
[blue]<script src="blah.php" type="text/javascript"></script>[/blue]
This will use the output of the php as an external script. This has uses, but it won't do what you want.
What you are trying to do needs to be done on the server.
<?
header("Content-type: application/x-javascript");
echo ...
I hope this is what you meant. Ohterwise, ignore this post and do what Bernard tells you to ;)
Welcome to WebmasterWorld, by the way.
Here is the script that's causing me trouble. Perhpas you can spot the error...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<script language="javascript" src="http://.../index.php?user=66175"></script>
</body>
</html>
When I type 'index.php?user=66175' directly in my browser I am able to $_GRT the value in index.php, but when I execute the above script in a file called text.html, nothing happens. I do however know that the script takes me to index.php, but apparently not the variable. What am I doing wrong?
PS. I realize that I have posted a similar message in the PHP forum...