title: Post Excel file through AJAX
body: <p>Is there any way to send an Excel file through an AJAX POST request? I've tried this, but I don't know how to wrap the file through the request.
  Can AJAX do this?</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form id='file-import' method="POST" enctype="multipart/form-data"&gt;
    &lt;meta name="csrf-token" content="{{ csrf_token() }}" /&gt;
    &lt;label&gt;Choose File&lt;/label&gt;
    &lt;div class="form-group"&gt;
      &lt;input type="file" name="file" required="required"&gt;
    &lt;/div&gt;
    &lt;button type="submit" class=""&gt;Import&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
    console.log('run');
    $('#file-import').submit(function(e) {
      e.preventDefault();
      let form_data = new FormData($(this)[0]);
      console.log(form_data);
      $('#content').hide();
      $('#page-loader').fadeIn();
      $.ajax({
        url: '/test/post',
        type: 'POST',
        data: 'form_data',
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        dataType: 'json',
        success: function(data) {
          console.log('success');
        },
        error: function() {
          console.log('error');
        }
      });
      $('#page-loader').fadeOut();
      $('#content').show();
    });
  });
  </code></pre>