cancel
Showing results for 
Search instead for 
Did you mean: 

PHP data to Javascript?

N/A

PHP data to Javascript?

Hey all,

I need to get some info from PHP (CGI server) to a DHTML/Javascript file on the regular server. Everything I have tried has failed due to the seperate servers. The only option I have left is appending the data to the url which I really don't want to do.

Any suggestions?
2 REPLIES
N/A

RE: PHP data to Javascript?

How about a php script that returns some javascript
code which sets passes the data you want..

Example

test.php on crofters
<?
$data_from_crofters = 'Howdy!';

echo 'var your_data="'.$data_from_crofters.'";';
?>

then in test.html on homepages.force9.net include

<SCRIPT language="JavaScript" src="http://cgi.username.force9.co.uk/test.php">

<SCRIPT language="JavaScript">
document.write(your_data);
</SCRIPT>

May work, may not. Just an idea.

Allan
N/A

RE: PHP data to Javascript?

sorry. forgot the </SCRIPT> on the end there.

<SCRIPT language="JavaScript" src="http://cgi.username.force9.co.uk/test.php"> </SCRIPT>