This question already has an answer here:
I've been stuck on this all day and I haven't been able to find an answer that solved my issue:
I need to make a PHP variable available in my Javascript file. Currently I'm using a fetchMarkers.php to retreive records from my database, and I would like to make this info available (they're arrays) in my javascript file.
How can I get this to work? I'm currently working with the PHP in my page--front.tpl.php file because I'm unsure of how to call it.
But, my question for now is: How do I make PHP Arrays available to my Javascript file? I've json_encode()d my arrays in the PHP with:
echo json_encode($latitudes);
echo json_encode($ar);
And I've tried multiple things but none of them worked (so many things that it just got me more and more confused). So therefor my question is just:
How can I access these two variables in my Javascript?