-1

Possible Duplicate:
Echo PHP variable from JavaScript?
How can I get a PHP variable to AJAX?

I'm trying to get some data from my database with php, and put it in a javascript variable. what is the easiest way to do that using JQuery ?

Community
  • 1
  • 1
W.W
  • 109
  • 1
  • 10

1 Answers1

0

This is easiest for me, where $var is your array in PHP, being set to the variable "a" in Javascript:

<script type="text/javascript">
var a = <?php echo json_encode($var); ?>;

</script>
circusdei
  • 1,967
  • 12
  • 28