Solved

Calling javascript from perl with Ajax

Posted on 2013-10-23
2
353 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

929 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now