-5

I have index.php and I have there some variable in php script. Now I have jqueryfunctions.js file. I would like to send this variable to this js file. I am pretty beginning person, and i am totally new to java script. Could someone tell me how to do this?

Deepak Rai
  • 2,163
  • 3
  • 21
  • 36
UberProCoder
  • 33
  • 1
  • 7

2 Answers2

2

You Can set the JS variable in PHP file.

<script>
    var my_val  = '<?php echo $php_var; ?>';
</script>
Deepak Rai
  • 2,163
  • 3
  • 21
  • 36
-2

First of all you must aware about server side scripting and client side scripting. PHP is only for server side scripting for process your client side requests. That is you can pass data to javascript only after page load or via ajax.

Lal krishnan S L
  • 1,684
  • 1
  • 16
  • 32