title: Set a value to HTML select while using Ajax and SweetAlert2
body: <p>I am building a form using SweetAlert2 + Ajax, but I have a problem with the <code>&lt;select&gt;</code> tag, so I will skip segments of the code that have nothing to do with the problem</p>
  <p>The Ajax sends the email to the PHP code, then with the email I make a MySQL query to get the full information from the user (name, age and country), I storage the info in an array and returns it to the ajax with <code>echo json_encode($arrayResult)</code>, then I print the data with SweetAlert2 but I have the problem that I dont know how to print it with the <code>&lt;select&gt;</code> tag, here is my code so you can understand me better...</p>
  <p>The Ajax + SweetAlert2</p>
  <pre><code>$.ajax({
      type: &quot;POST&quot;,
      url: &quot;getuserdata.php&quot;,
      data: {
          email : emailX
      },
      success: function (response){
         response = JSON.parse(response);
         Swal.fire({
             html:`&lt;div&gt;Insert your new information&lt;/div&gt;
             &lt;div&gt;
                  &lt;span&gt;Name&lt;/span&gt;
                  &lt;input id=&quot;name&quot; type=&quot;text&quot; value=&quot;${response.name}&quot;&gt;
             &lt;/div&gt;
             &lt;div&gt;
                  &lt;span&gt;email&lt;/span&gt;
                  &lt;input id=&quot;email&quot; type=&quot;email&quot; value=&quot;${response.email}&quot;&gt;
             &lt;/div&gt;
             &lt;div&gt;
                  &lt;span&gt;Age&lt;/span&gt;
                  &lt;input id=&quot;age&quot; type=&quot;text&quot; value=&quot;${response.age}&quot;&gt;
             &lt;/div&gt;
             &lt;select id=&quot;country&quot;&gt;
                  &lt;option value=&quot;USA&quot;&gt;USA&lt;/option&gt;
                  &lt;option value=&quot;England&quot;&gt;England&lt;/option&gt;
                  &lt;option value=&quot;Canada&quot;&gt;Canada&lt;/option&gt;
             &lt;/select&gt;
             `,
           })
         }
      })
  </code></pre>
  <p>An just in case here is the PHP:</p>
  <pre><code>&lt;?php
  
      $mysqli = new mysqli(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;,&quot;store&quot;);
      $mysqli-&gt;set_charset(&quot;utf8&quot;);
  
      $email = $_POST['email'];
  
      $sql = &quot;SELECT * FROM clients WHERE email = '&quot;.$email.&quot;'&quot;;
      $result = mysqli_query($mysqli, $sql);
      $data = $result-&gt;fetch_assoc();
      $count = mysqli_num_rows($result);
  
      $arrayResult = [];
  
      if($count &gt; 0){
          $arrayResult['name'] = $data['name'];
          $arrayResult['age'] = $data['age'];
          $arrayResult['country'] = $data['country'];
      }else{
          $arrayResult['name'] = '';
          $arrayResult['age'] = '';
          $arrayResult['country'] = '';
      }
  
      echo json_encode($arrayResult);
  
  ?&gt;
  </code></pre>
  <p>Of course if this was a basic HTML code I would have solve it but it is inside a Javascript + Inside Ajax + inside a SweetAlert2 and I have try all the ways I know but dont work.</p>
  <p>The country can be ONLY one of those 3 (USA, England and Canada), there is a <code>${response.country}</code> that resturns one of those 3 countries.</p>
  <p>So what I want is that depending of the country returned It will be the one selected in the <code>&lt;option&gt;</code> of the <code>&lt;select&gt;</code></p>