title: Post form data with AJAX and trigger PHPExcel action with one submit
body: <p>I have a form where the submit posts data via AJAX and then refreshes a div without reloading the complete page. So far ok and it works perfectly.</p>
  
  <p>My problem: I need to add a second action to this form.
  Same values but different action.
  Both actions work perfectly alone, but I just can't get them working within the same submit.</p>
  
  <p>The second action is a script generating an xls with <code>PHPExcel</code> and triggering a download.</p>
  
  <p>How do I include the following <code>process_xls.php</code> into the AJAX so it's triggered with the same submit?</p>
  
  <p>The process_xls.php</p>
  
  <pre><code>$year = $_POST['year'];
  $nmbr = $_POST['nmbr'];
  $code = $_POST['code'];
  
  include("excel/PHPExcel.php");
  
  $objPHPExcel = new PHPExcel();
  
  // ....
  // code creating xls here
  // ....
  
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment;filename="Summary.xlsx"');
  header('Cache-Control: max-age=0');
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  $objWriter-&gt;save('php://output');
  exit;
  </code></pre>
  
  <p>The HTML:</p>
  
  <pre><code>&lt;div id="container"&gt;
   &lt;form id="form_year" method="post"&gt;
   &lt;input type="hidden" name="year" value="2015"&gt;
   &lt;input type="hidden" name="nmbr" value="22"&gt;
   &lt;input type="hidden" name="code" value="5Tvfr5T"&gt;
   &lt;div class="button-small"&gt;&lt;input type="submit" name="" value=""&gt;&lt;/div&gt;
   &lt;/form&gt;
  
   // ....
   // some data displayed here
   // ....
  
  &lt;/div&gt;
  </code></pre>
  
  <p>(the class "<code>button-small</code>" is only for CSS)</p>
  
  <p>The Javascript</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function()
  {
   $(document).on('submit', '#form_year', function()
   {      
    var data = $(this).serialize(); 
  
    $.ajax({  
    type : 'POST',
    url  : 'process_year_data.php',
    data : data,
    success :  function(data)
     {
      $("#form_year").fadeOut(500).hide(function()
      {
       $("#container").fadeIn(500).show(function()
       {
       $("#container").html(data);
       });
      });
     }
    });
    return false;
   });
  
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help greatly appreciated !</p>