How to do an Ajax GET request to get data from rails and pass it to javascript(google maps)?

后端 未结 1 1736
清歌不尽
清歌不尽 2021-01-06 13:31

I have a model Locations with two columns latitude and longitude. I want to find a way where I can get the list of locations and pass them to google maps using Ajax and java

相关标签:
1条回答
  • 2021-01-06 14:34

    Oh I was able to find my way to get the list of locations. The controller and view are left untouched.

    I added the following ajax in map.js which did the work for me.

    $.ajax({
            type: "GET",
            dataType: "json",
            url: "/locations",
            success: function(data){}
        }); 
    

    Now data can be passed to the marker object in google maps.

    0 讨论(0)
提交回复
热议问题