Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
AJAX Data No Showing in a Leaflet Popup Easy Button

I am trying to add JSON response details from an AJAX call to a leaflet popup. I can populate the data using a modal in the html but I want to use this as an easy button function instead.

I have tried a few options but nothing is working to populate the data in the popup and it shows as blank. Everything else is working as it should and the button is added onto the map.

Any ideas?

$('#selCountry').on('change', function(){
  $.ajax({
      url: "php/restCountries.php",
      type: 'POST',
      dataType: 'json',
      data: {
          country: $('#selCountry').val()   
      },
      success: function(result) {
        
          console.log('restCountries', result);
          if (result.status.name == "ok") {
              iso2CountryCode = result.data.alpha2Code;
              var countryName2 = result.data.name;
              countryName = countryName2.replace(/\s+/g, '_');
              
              L.easyButton('<img src="images/info.png">', function(btn, map){
    
              var detailsPopup = L.popup($('#countryName').html('<strong> Country: ' + result['data']['nativeName'] + '</strong>') +
              $('#txtCurrencyCode').html('<strong> Capital City: ' + result['data']['capital'] + '<br> Currency Symbol: '+ result.currency.symbol + '<br> Currency Name: '  + result.currency.name + '<br> Currency Code: ' + result.currency.code + '</strong>')).setContent(popup);
                  detailsPopup.setLatLng(map.getCenter()).openOn(map);
              }).addTo(map);
              
              console.log(result.data.latlng[0]);
              
              var currentLat = result.data.latlng[0]
              var currentLng = result.data.latlng[1]
              
              marker = L.marker;
              
               L.marker([currentLat, currentLng], {icon: redMarker}).addTo(map);
              
                      if (marker != undefined) {
              map.removeLayer(marker);
        };
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda