I have an index file which contains google map just (map through javascript) . when I search some place, it also pins its nearby on the map that's good now . But what I want is , when ever I click on marker on the map . It should show a div of place detail on the same page below the map . I made ajax assets/javascript/customer.js , pointing the URL at customer controller in controller/customers/index I get the whole page in response . that's we know is wrong . Here is my js file content
$.ajax({
url: "/",
async: false,
method: "post",
data: { "place_id" : place["place_id"] },
success: function(data){
alert('success');
}
});
infoWindow.open(map, marker);
buildIWContent(place);
});
And my controller function is
def index
if params[:place_id]
@place = Places.find(params['place_id'])
end
end
And this is what I want to show in my index page i.e html.erb
<% if @place %>
<div class='place-name'><% @place.name %></div>
<% end %>
I know there are partials supported in rails but I don't know whether those will work or not . I'm new to Rails so pardon me if you find my question very silly. I just want to show this place-name div through ajax magic, whether through partials or just as it is.