Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling javascript from perl with Ajax

Posted on 2013-10-23
2
Medium Priority
?
363 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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
 
LVL 1

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Six Sigma Control Plans

636 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