Embed php into Javascript
February 24th, 2009
No comments
In javascript you cannot read variables from a server instanly however if you embed your php code you may pass variables into javascript code.
So php can pass its variables when page loads. Here is an example using jquery
< ?php $variable = 'Here is value'; ?>
<script type= "text/javascript">
$(document).ready(function(){
var button = < ?php echo $variable; ?> ;
});
</script>
Tweet
Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the

Recent Comments