title: Ajax wont stop if false
body: <p>I have problem with my ajax,<br></p>
  <p>here my index:</p>
  <pre><code>&lt;form name=&quot;add_name&quot; id=&quot;add_name&quot;&gt;
    &lt;div class=&quot;col-lg-12&quot;&gt;
      &lt;div class=&quot;form-row mb-2&quot;&gt;
        ID Kurir :
        &lt;div class=&quot;col&quot;&gt;
          &lt;input type=&quot;text&quot; id=&quot;idkurir&quot; name=&quot;idkurir&quot; placeholder=&quot;Input ID Kurir&quot; class=&quot;idkurir&quot; autofocus /&gt;
        &lt;/div&gt;
        Nama Kurir :
        &lt;div class=&quot;col&quot;&gt;
          &lt;input type=&quot;text&quot; id=&quot;namakurir&quot; name=&quot;namakurir&quot; value=&quot;Nama Kurir&quot; class=&quot;namakurir&quot; readonly /&gt;
        &lt;/div&gt;
        No Laporan :
        &lt;div class=&quot;col&quot;&gt;
          &lt;input type=&quot;text&quot; id=&quot;nolaporan&quot; name=&quot;nolaporan&quot; value=&quot;No Laporan&quot; readonly /&gt;
        &lt;/div&gt;
        Date :
        &lt;div class=&quot;col&quot;&gt;
          &lt;?php $now=date('d-m-Y H:i'); ?&gt;
          &lt;input type=&quot;text&quot; name=&quot;date&quot; value=&lt;?php echo &quot;'$now'&quot;; ?&gt; readonly /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-lg-6&quot;&gt;
          &lt;table class=&quot;table table-bordered&quot; id=&quot;dynamic_field1&quot;&gt;
            &lt;tr&gt;
              &lt;td colspan=2 align=center&gt;&lt;strong&gt;Antar Ulang&lt;/strong&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;awbau[]&quot; placeholder=&quot;Enter AWB&quot; class=&quot;form-control name_listau&quot; /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;button type=&quot;button&quot; name=&quot;addau&quot; id=&quot;addau&quot; class=&quot;btn btn-success&quot;&gt;Add More&lt;/button&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;
  
        &lt;div class=&quot;col-lg-6&quot;&gt;
          &lt;table class=&quot;table table-bordered&quot; id=&quot;dynamic_field2&quot;&gt;
            &lt;tr&gt;
              &lt;td colspan=2 align=center&gt;&lt;strong&gt;Undelivery&lt;/strong&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;awbundel[]&quot; placeholder=&quot;Enter AWB&quot; class=&quot;form-control name_listundel&quot; /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;button type=&quot;button&quot; name=&quot;addundel&quot; id=&quot;addundel&quot; class=&quot;btn btn-success&quot;&gt;Add More&lt;/button&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;center&gt;&lt;input type=&quot;button&quot; name=&quot;submit&quot; id=&quot;submit&quot; class=&quot;btn btn-info btn-block mb-4 mr-2&quot; value=&quot;Submit Data&quot; /&gt;&lt;/center&gt;
  &lt;/form&gt;
  </code></pre>
  <p>here my ajax script :</p>
  <pre><code>$(document).on(&quot;keypress&quot;, &quot;.idkurir&quot;, function(e) {
    var idkurir = $('#idkurir').val();
    if (e.which == 13) {
  
      $.ajax({
        type: &quot;POST&quot;,
        url: &quot;checkdata.php&quot;,
        data: {
          idkurir: idkurir
        },
        success: function(response) {
          if (response == 1) {
            alert(&quot;Kurir sudah laporan&quot;);
          } else {
            if (response == &quot;ID Kurir tidak di temukan&quot;) {
              alert(response);
            } else {
              var d = new Date();
              var today_date = (&quot;0&quot; + d.getDate()).slice(-2) + (&quot;0&quot; + (d.getMonth() + 1)).slice(-2);
              $('#nolaporan').val(idkurir + today_date);
              $('#namakurir').val(response);
            }
          }
        }
      });
    }
  });
  </code></pre>
  <p>and here my checkdata to check if data exist :</p>
  <pre><code>session_start();
  $connect = mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;);
  mysql_select_db(&quot;reportchecker&quot;, $connect);
  $idkurir = $_POST[&quot;idkurir&quot;];
  $nolaporan = $idkurir . date(&quot;dm&quot;);
  $sql = &quot;SELECT * FROM jampulang WHERE nolaporan = '$nolaporan'&quot;;
  $result = mysql_query($sql, $connect);
  $count = mysql_num_rows($result);
  $response = [];
  $sql2 = &quot;SELECT * FROM kurir WHERE idkurir = '$idkurir'&quot;;
  $result2 = mysql_query($sql2, $connect) or die(mysql_error());
  $count2 = mysql_num_rows($result2);
  if ($count == 1) {
      echo &quot;1&quot;;
  } else if ($count2 == 1) {
      $row = mysql_fetch_array($result2) or die(mysql_error());
      echo $row['nama'];
  } else {
      echo &quot;ID Kurir tidak di temukan&quot;;
  }
  </code></pre>
  <p>my problem is when response from checkdata = &quot;ID Kurir tidak di temukan&quot;, ajax not showing alert and stop update field nolaporan and nama kurir</p>
  <pre><code>$('#nolaporan').val(idkurir + today_date);
  $('#namakurir').val(response);
  </code></pre>
  <p>in my script above when reponse &quot;ID Kurir tidak di temukan&quot; still update field nolaporan and namakurir.</p>