I have a php function that stores some values in a longitude and latitude array. These array do hold the right values within php since print_r() within php shows me that the array is correct.
Now, I pass on this array to JS in this manner:
<script> var lati_array = "<?php echo json_encode($latitude_array); ?>"; var longi_array = "<?php echo json_encode($longitude_array); ?>"; alert(lati_array); </script>
In the beginning, when I open the HTML file, it shows me an empty array (which is expected because the PHP arrays aren't filled yet). Then user enters something, the php arrays are filled up with longitudes and latitudes. These values should now be passed to JS. However, it doesn't alert anything after that. I can't be sure if array is successfully passed to JS. What am I missing?