title: Trying to get Leaflet Map to change map view to selected country option
body: <p>I have a <code>&lt;select&gt;</code> list populated with a bunch of country names. When an option is selected, the <code>value</code> attribute (the ISO of the country) of the <code>&lt;option&gt;</code> element is used in a PHP cURL routine to search through a JSON file to return a latlng of the country capital. I want this latlng info to then adjust the map accordingly, in other words, set the view to the country selected.</p>
  <p>getPHP.js:</p>
  <pre><code>$('#countrySearch').click(function() {
      console.log(&quot;Button clicked&quot;);
      $.ajax({
          url: &quot;libs/php/getCountryISO.php&quot;,
          type: 'POST',
          dataType: 'json',
          data: {
              iso: $('#countrySelect option:selected').val()
          },
          success: function(result) {
  
              console.log(JSON.stringify(result));
              console.log(&quot;JSON stringified&quot;);
  
              if (result.status.name == &quot;ok&quot;) {
  
                  console.log(&quot;All recieved well.&quot;);
                  $(mymap).setView(result['data']['latlng']);
  
              }
          
          },
          error: function(jqXHR, textStatus, errorThrown) {
              console.log(jqXHR);
          }
      })
  });
  </code></pre>
  <p>script.js:</p>
  <pre><code>//Loading Map
  var mymap = L.map('mapid').locate({setView: true, maxZoom: 16}); //Set Location to Users Location
        L.tileLayer('https://tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png?access-token=nr1yo2LitcA3V1WiGnpQNQTE2ooNfxu7xxHlxldA7OirWsWMyBSLgoSzyVksXpdG', {}).addTo(mymap);
        mymap.attributionControl.addAttribution(&quot;&lt;a href=\&quot;https://www.jawg.io\&quot; target=\&quot;_blank\&quot;&gt;&amp;copy; Jawg&lt;/a&gt; - &lt;a href=\&quot;https://www.openstreetmap.org\&quot; target=\&quot;_blank\&quot;&gt;&amp;copy; OpenStreetMap&lt;/a&gt;&amp;nbsp;contributors&quot;);
  console.log(&quot;Leaflet Map Loaded.&quot;)
  </code></pre>
  <p>I've tried fiddling around with the jQuery selector to different things such as <code>'mapid'</code> but currently I run into the issue of:</p>
  <pre><code>Uncaught TypeError: $(...).setView is not a function
      at Object.success (getPHP.js:19)
      at c (jquery.min.js:2)
      at Object.fireWith [as resolveWith] (jquery.min.js:2)
      at l (jquery.min.js:2)
      at XMLHttpRequest.&lt;anonymous&gt; (jquery.min.js:2)
  </code></pre>