Jump to content

Variables from php to js


cfgcjm

Recommended Posts

Ajax does seem to be worth a look into, but in the meanwhile:

 

<?php
$phpvariable = "foo"; // Or whatever
?>

<script type="text/javascript">
var jsvariable = "<?=$phpvariable?>";
</script>

 

Works for me, but you should use Ajax if you intend to use server stored data in a client side application and then reupload it back to the server, you want to be careful about javascript injections in the address bar and such.

 

Archived

This topic is now archived and is closed to further replies.

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