Bear with me here while I explain this because it’s pretty complex.
Essentially what I’m doing is scraping job titles, locations of the jobs (city and state), and company names from a job hosting website into separate arrays. The location is then passed to Google’s Static Geocoding API via a local proxy server, then the data is sent back as XML and the tags latitude and longitude are parsed out and stored in JavaScript variables called lat and long. The variables lat and long are then passed to a Google Maps script where pins are placed on the map based on the variables. When the user clicks on the pin an info box pops up with the Company name and Job Title.
All of this I have working successfully for a single instance, the thing I’m lost on is I need to do this 25 times. I was thinking about creating a function to encase the AJAX call to the Google API and the function to place the pins but it was blowing my mind since they are PHP variables that need to be passed to JavaScript and having a whole bunch of <?PHP echo [i]var[/i] ?>tags in the parameters of the function didn’t look correct to me.
A friend suggested outputting those PHP variables to hidden HTML forms and then using JavaScript to read the form values, then place those values in JavaScript arrays for use later.
What would be the recommended way to do this? Here’s my code in its entirety: http://pastebin.com/pP3uQUxV