Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:01:57+00:00 2026-05-16T15:01:57+00:00

I have a page which shows a Google map. I’d like to use Javascript

  • 0

I have a page which shows a Google map. I’d like to use Javascript to fetch several points from my database and place them as markers on the map. So the flow is:

  1. Javascript calls a Rails action with parameters.
  2. Rails queries the database.
  3. Rails returns the response.
  4. Javascript updates the page (Rails can’t do this since it must be aware of the JS map object).

What is the current best practice for implementing such a scenario? I know I can use a Prototype Ajax.Request to call the Rails action but how should I call the Javascript function which updates the page when the Rails action returns its results? Should I update some hidden HTML and have an event listener listen on it? Or is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:01:57+00:00Added an answer on May 16, 2026 at 3:01 pm

    You have a couple options.

    1) Your ajax request can be of type ‘script’ which will allow you to write an action_name.js file that your rails app renders. This has access to all of your page items (it’s not likely to have access to your map object however unless that’s public)

    2) My preferences is to have your javascript query for json data (type ‘json’) which then allows you to use that data as you please in your JS. I don’t use prototype but the general flow would be.

    • initialize your map
    • query for some json data using ajax (ie. locations with lat/long)
    • rails reponds_to do |f| f.json { render :json => some_hash} end
    • in your ajax callback (back in javascript), iterate over json data and add points to your map appropriately. (or do whatever you like)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At current i have an index page which shows values from an XML page
i have a WebView of an html page which shows only one image http://www.google.fr/intl/en_com/images/srpr/logo1w.png
Hi I have a page in my java/jsp based web application which shows list
I have a web page with a read-only text box which shows some HTML
I have several forms on one page which are submitted using ajaxForm and show
I have a page set up to show only posts from one category, which
I have page which is redirected from htaccess. now I can pass the German
I have noticed that, from Google Maps page, you can get an embed link
I have a page which uses some data from datastore, and if the data
i use google map in my newest project ,and i have a combo box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.