title: How to solve an error "oTable.draw is not a function" in filtering datatables?
body: <p>I have a search form above the datatables. When I try to search, I have got the data shows in JSON format, not filtering the datatables. The error is </p>
  
  <blockquote>
    <p>Uncaught TypeError: oTable.draw is not a function</p>
  </blockquote>
  
  <p>Here is the javascript:<br></p>
  
  <pre><code>$(document).ready(function(){
      var oTable = $('#surat').DataTable({
          processing: true,
          serverSide: true,
          ajax: {
              url: '{!! route("surat") !!}',
              data: function (d) {
                  d.jenis_surat = $('input[name=jenis_surat]').val();
                  d.nomor_surat = $('input[name=nomor_surat]').val();
                  d.perihal = $('input[name=perihal]').val();
              }
          },
          columns: [
              {data: 'no', name: 'no'},
              {data: 'jenis_surat', name: 'jenis_surat'},
              {data: 'nomor_surat', name: 'nomor_surat'},
              {data: 'perihal', name: 'perihal'},
              {data: 'status', name: 'status'}
          ]
      });
  
      $('#search_form').on('submit', function(e) {
          oTable.draw();
         e.preventDefault();
      });
    });
  </code></pre>
  
  <p>And this is the controller:<br></p>
  
  <pre><code>public function carisuratdata(Request $request)
  {
      $surats = Surat::select(['id_surat', 'id_jenis_surat', 'nomor_surat','perihal', 'tanggal_surat', 'masa_berlaku_from', 'masa_berlaku_to', 'ringkasan', 'tag', 'id_publish', 'tanggal_publish'])-&gt;get();
  
      return Datatables::of($surats)
          -&gt;filter(function ($instance) use ($request) {
              if ($request-&gt;has('jenis_surat')) {
                  $instance-&gt;collection = $instance-&gt;collection-&gt;filter(function ($row) use ($request) {
                      return Str::contains($row['jenis_surat'], $request-&gt;get('jenis_surat')) ? true : false;
                  });
              }
  
              if ($request-&gt;has('nomor_surat')) {
                  $instance-&gt;collection = $instance-&gt;collection-&gt;filter(function ($row) use ($request) {
                      return Str::contains($row['nomor_surat'], $request-&gt;get('nomor_surat')) ? true : false;
                  });
              }
              if ($request-&gt;has('perihal')) {
                  $instance-&gt;collection = $instance-&gt;collection-&gt;filter(function ($row) use ($request) {
                      return Str::contains($row['perihal'], $request-&gt;get('perihal')) ? true : false;
                  });
              }
          })
  
          -&gt;make(true);
  
  }
  </code></pre>
  
  <p>Here is the JSON:<br>
  <a href="https://i.stack.imgur.com/Hdu3N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hdu3N.png" alt="enter image description here"></a></p>