Can the infowindow be customized to have ajax calls that then updates the infowindow html content?

5 posts / 0 new
Last post
jabberwayne
Can the infowindow be customized to have ajax calls that then updates the infowindow html content?

I want to be able to display a button on the infowindow, which when user clicks on, and depending on whether the operation was succesful or failure, displays message in the same info window where the button was. Is that possible? If so, how?

Many thanks!


MQBrianCoakley
Add the button html to the
Add the button html to the content string. Here is now I did it for a search result in Leaflet.   .bindPopup(c.name + '<input type="button" onclick="route(' + a + ')" value="GO"/>')

jabberwayne
Hi,

Hi,

Thanks for the response. I am looking to achieve something like this:

1. add mapquest map on my webpage

2. when user clicks on the button on the infowindow, make an ajax call to my webservice that does business logic and returns 1 or 0.

3. based on what the webservice returns, display info accordingly on the infowindow.

Another side question, does the ajax call have to be an absolute URL? 

 


MQBrianCoakley
I don't see why relative
I don't see why relative paths back to the web page's server would be a problem. But I haven't tried it specifically.

andrsonmathew
Can the infowindow be customized to have ajax calls that then up

As was suggested in the answer I decided to move the calls to setContent and open to a separate function. 
function load_content(marker, id){
$.ajax({
url: 'aulas/show/' + id,
success: function(data){
infowindow.setContent(data);
infowindow.open(map, marker);
}
});
}