Solved

Calling javascript from perl with Ajax

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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 invoke it on a web page. 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.: (CODE)

803 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