title: AJAX Respond Not Catched by PHP file
body: <p>We are on progress creating web page for live search and update file in bulk using JQUERY AJAX method. The files consist of index.php (for display to user and Javascript), and multiple_update.php (for fetch and update file in bulk). Initial reference we got is from <a href="https://www.webslesson.info/2018/09/update-multiple-rows-with-checkbox-in-php-using-ajax-jquery.html" rel="nofollow noreferrer">here from webslesson website</a>, but it does not have any reference for searching the record, hence we search for help for our journey.</p>
  <p>Below is our index.php file</p>
  <pre><code>&lt;div class=&quot;content-wrapper&quot;&gt;
      &lt;div class=&quot;content-heading&quot;&gt;
          &lt;div&gt;STO Monitoring&lt;small&gt;Tables, one step forward.&lt;/small&gt;&lt;/div&gt;
          &lt;div class=&quot;ml-auto&quot;&gt;&lt;input type=&quot;text&quot; id=&quot;search&quot; placeholder=&quot;Search&quot; /&gt;&lt;/div&gt;
          &lt;div id=&quot;display&quot;&gt;&lt;/div&gt;
          &lt;div class=&quot;ml-auto&quot;&gt;
              &lt;button class=&quot;btn btn-primary btn-lg&quot; type=&quot;button&quot; data-toggle=&quot;modal&quot; data-target=&quot;#myModalSmall&quot;&gt;&lt;i class=&quot;fas fa-plus-square&quot;&gt;&lt;/i&gt; Add Record&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;form method=&quot;post&quot; id=&quot;update_form&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
              &lt;div class=&quot;card-body&quot;&gt;
                  &lt;table class=&quot;display&quot; id=&quot;example&quot; style=&quot;width:100%&quot;&gt;
                      &lt;thead&gt;
                         &lt;tr&gt;
                            &lt;th width=&quot;3%&quot;&gt;&lt;/th&gt;
                            &lt;th width=&quot;5%&quot;&gt;No&lt;/th&gt;
                            &lt;th width=&quot;15%&quot;&gt;STO&lt;/th&gt;
                            &lt;th width=&quot;20%&quot;&gt;PN&lt;/th&gt;
                            &lt;th width=&quot;8%&quot;&gt;Qty&lt;/th&gt;
                            &lt;th width=&quot;10%&quot;&gt;From&lt;/th&gt;
                            &lt;th width=&quot;10%&quot;&gt;Dest&lt;/th&gt;
                            &lt;th width=&quot;15%&quot;&gt;Status&lt;/th&gt;
                            &lt;th width=&quot;14%&quot;&gt;Remark&lt;/th&gt;
                         &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;&lt;/tbody&gt;
                   &lt;/table&gt;
                   &lt;div align=&quot;left&quot;&gt;
                      &lt;input type=&quot;submit&quot; name=&quot;multiple_update&quot; id=&quot;multiple_update&quot; class=&quot;btn btn-info&quot; value=&quot;Multiple Update&quot; /&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
             &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
   .....
  </code></pre>
  <p>Below is script inside our index.php, the one we suspect need troubleshoot at the moment.</p>
  <pre><code>&lt;script&gt;
  function fill(Value) {
      $('#search').val(Value);
      if (name == &quot;&quot;) {
          $(&quot;#display&quot;).html(&quot;&quot;);
      }
  }
  
  $(document).ready(function(){  
  
      function fetch_data()
      {
          $(&quot;#search&quot;).keyup(function() {
              var name = $('#search').val();
              if (name == &quot;&quot;) {
                  //Assigning empty value to &quot;display&quot; div in &quot;search.php&quot; file.
                  $(&quot;#display&quot;).html(&quot;empty&quot;);
              } else {
                  $.ajax({
                      url:&quot;multiple_select.php&quot;,
                      method:&quot;POST&quot;,
                      dataType:&quot;json&quot;,
                      data: {
                         //Assigning value of &quot;name&quot; into &quot;search&quot; variable.
                         search: name
                      },
                      success:function(data)
                      {
                          var html = '';
                          for(var count = 0; count &lt; data.length; count++) {
                              html += '&lt;tr&gt;';
                              html += '&lt;td&gt;&lt;input type=&quot;checkbox&quot; id=&quot;'+data[count].num+'&quot; data-num=&quot;'+data[count].num+'&quot; data-sto=&quot;'+data[count].sto+'&quot; data-pn=&quot;'+data[count].pn+'&quot; data-qty=&quot;'+data[count].qty+'&quot; data-supplant=&quot;'+data[count].supplant+'&quot; data-dest=&quot;'+data[count].dest+'&quot; data-stat=&quot;'+data[count].stat+'&quot; data-remark=&quot;'+data[count].remark+'&quot; class=&quot;check_box&quot;  /&gt;&lt;/td&gt;';
                              html += '&lt;td&gt;'+(count+1)+'&lt;/td&gt;';
                              html += '&lt;td&gt;'+data[count].sto+'&lt;/td&gt;';
                              html += '&lt;td&gt;'+data[count].pn+'&lt;/td&gt;';
                              html += '&lt;td&gt;'+data[count].qty+'&lt;/td&gt;';
                              html += '&lt;td&gt;&lt;span class=&quot;btn btn-oval btn-primary&quot;&gt;'+data[count].supplant+'&lt;/span&gt;&lt;/td&gt;';
                              html += '&lt;td&gt;&lt;span class=&quot;btn btn-oval btn-warning&quot;&gt;'+data[count].dest+'&lt;/span&gt;&lt;/td&gt;';
                              html += '&lt;td&gt;'+data[count].stat+'&lt;/td&gt;';
                              html += '&lt;td&gt;'+data[count].remark+'&lt;/td&gt;&lt;/tr&gt;';
                          }
                          $('tbody').html(html);
                      }
                  });
              }
          });
      }
  
  fetch_data();
  
  $(document).on('click', '.check_box', function(){
   .....
  &lt;/script&gt;
  </code></pre>
  <p>We modify the AJAX to see if the input can be catched by the network, below is code for multiple_update.php</p>
  <pre><code>&lt;?php
  
  include('multiple_connection.php');
  $name = $_POST['search'];
  echo $name;
  
  $query = &quot;SELECT * FROM matreq_list, sto_list WHERE matreq_list.sto = sto_list.sto AND sto_list.sto LIKE '%$name%' LIMIT 5;
  
  $statement = $connect-&gt;prepare($query);
  
  if($statement-&gt;execute()) {
      while($row = $statement-&gt;fetch(PDO::FETCH_ASSOC)) {
          $data[] = $row;
      }
      echo json_encode($data);
  }
  ?&gt;
  </code></pre>
  <p>We want to make every search is captured via AJAX, and respond from network will be live-reflected in our index file. Below is our expected final result (this result is without &quot;LIKE&quot; in mysql statement to show the result only) :</p>
  <p><img src="https://i.stack.imgur.com/9qC45.jpg" alt="Expected Result" /></p>
  <p>And we confirm AJAX can handle our input, below is the image :</p>
  <p><img src="https://i.stack.imgur.com/9ybIq.jpg" alt="AJAX capture and respond" /></p>
  <p>--UPDATE-- Below is error messages :
  Error messages</p>
  <p><a href="https://i.stack.imgur.com/KxRoA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KxRoA.jpg" alt="enter image description here" /></a></p>
  <p>However, after we fired the input, nothing cames up in our index.php file. Network shows good respond, but the HTML is not responding the way we expected it to do. Please kindly advise us sir, what is wrong with our method and what should we fix?</p>
  <p>Thank you and appreciate your kind help in our case</p>
  <p>=====UPDATE=====</p>
  <p>2020-07-02 : As mentioned by mr Nadir Baoun, tried to change the order of jquery.js and put it above the bootstrap.js, and somehow my table now able to search some part or whole part of the data.</p>
  <p>Before :</p>
  <pre><code>.....
   &lt;script src=&quot;vendor/datatables.net/js/jquery.dataTables.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;vendor/datatables.net-bs4/js/dataTables.bootstrap4.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;vendor/datatables.net-responsive-bs/js/responsive.bootstrap.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;vendor/jquery/dist/jquery3.5.1.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;vendor/datatables.net/dist/js/jquery.dataTables.min.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>After ordered : I move the jquery to the top of all codes.</p>
  <p>and below is network screenshot :</p>
  <p><a href="https://i.stack.imgur.com/1du2x.jpg" rel="nofollow noreferrer">After change order of javascript</a></p>
  <p>Surprisingly, this work well :D</p>