title: jquery ajax - how to use response in success
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>page.php
  
  $sqlQuery = "";
  $result = $mysqli-&gt;query($sqlQuery);
  if (mysqli_affected_rows($mysqli) &gt; 0) {
      echo "success";
  } else {
      echo "error";
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I want to use response text in success but with if condition is not working.
  How can i use with if.</p>
  
  <p>Thanks for your help.</p>
  
  <pre><code>$.ajax({
      metod: "POST",
      url: "page.php",
      data: {data},
      success: function (response) {
          console.log(response); // It is working
          notification("success"); // It is working
  
          // response text is succes or error
  
          if (response == 'success') {
              btnLabel.html("DONE"); // It is not working
          } else if (response == 'error') {
              btnLabel.html("ERROR"); // It is not working
          }
      },
      error: function (err) {
          notification("error"); // It is working
      }
  });
  </code></pre>