Sunday, 15 March 2015

How to use PHP in Javascript? -



How to use PHP in Javascript? -

i have script:

<script type="text/javascript"> $(function(){ $(".scratchcard").rabidscratchcard({ foregroundimage:"images/cards/card-prev.png", backggroundimage:"images/cards/card1-3-8.png", revealradius:7 }); }); </script>

the next want is, alter line of foregroundimage to:

foregroundimage:"<?php echo $path . $img ?>",

do have utilize ajax in javascript? or how work?

assuming script tag embedded within .php page (or file containing php has mime type webserver has been configured execute), can interpolate php within page so:

<script type="text/javascript"> $(function(){ $(".scratchcard").rabidscratchcard({ foregroundimage: "<?php echo $path . $img ?>", backggroundimage:"images/cards/card1-3-8.png", revealradius:7 }); }); </script>

javascript php

No comments:

Post a Comment