Solved

Calling javascript from perl with Ajax

Posted on 2013-10-23
2
359 Views
Last Modified: 2013-10-28
Hi,
I have a web page with a Google Map on it. The google map shows the user their current location (using HTML5).
There is a drop down on the page with some town names.
When a user selects a town name from the drop down, the event fires off a javascript function using AJAX, which then calls a perl script. The perl script queries a database and gets coords for the town the user selected in the drop down.
The next thing I *want* to do is place a marker on the map that shows the person where the town they selected is.
The part that has got me stumped is once I am in the perl script through the Ajax call, how do I pass the coords back to a javascript to put the marker on the map?

The only solution I can think of is to redraw the entire page in the perlscript, passing the coords to a javascript function using something like this
<body onload=placeMarker(lat1,lat2)>
I was hoping there was some other way I could do it that would be more elegant that would allow me to just pass back coords to the javascript without having to redraw the whole page.

Anyone?

Thanks,
Nacht
0
Comment
Question by:nachtmsk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39596357
I believe that all the code you need is on this page: https://developers.google.com/maps/articles/phpsqlsearch_v3  That version returns the info in XML format.   On this page https://developers.google.com/maps/documentation/javascript/basics , they have a link to a lot of code sample for different displays.
0
 

Author Closing Comment

by:nachtmsk
ID: 39606772
Just what I needed. Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question