title: Showing API data on leaflet.js using PHP and Javascript
body: <p>I'm trying to show currency exchange rates data of each country on popup in leaflet.js I'm using the following code.</p>
  <pre><code>function makePopupContent(country) {
      $.ajax({
          url: &quot;php/opencage.php&quot;,
          type: 'POST',
          dataType: 'json',
          data: {
              code: country.properties.currency    
          },
          
          success: function(result) {
              currencydata=result['data'];
              console.log(currencydata);
              $('#exchange').html(currencydata); 
         },
          //if there is no success in retrieving data from api
          error: function(jqXHR, textStatus, errorThrown) {
              console.log(&quot;error&quot;)
          }
      }); 
  
      return `
      &lt;div&gt;
          &lt;h4&gt;${country.properties.country}&lt;/h4&gt;
          &lt;p&gt;Capital:${country.properties.city}&lt;/p&gt;
          &lt;p&gt;Currency:${country.properties.currency}&lt;/p&gt;
          &lt;p id=&quot;exchange&quot;&gt;&lt;/p&gt;
          
          
      
      &lt;/div&gt;
    `
    
  }
  </code></pre>
  <p>I'm getting the data from api correctly but how should I display it in each pop for each country?</p>