I’m using Google Maps to make a map that can load markers with lat/lng data stored in a database. I want there to be three different ‘layers’ that the user can load by clicking buttons. When the button is clicked, a php function is executed on the server creating an xml file from the information on the database. An AJAX function is then called to pull this xml data that is then used to create the map markers.
Rather than have separate PHP functions for each ‘layer’ (which would be the same thing except for the line with the SQL query), is there a way to pass a variable from the javascript in the AJAX to the PHP?
I’m using Google Maps to make a map that can load markers with lat/lng
Share
If your using AJAX requests it’s pretty easy to pass variables to a php file. Here is a quick example.
Then in your php file you simple access the varables using