title: Download a file and redirect it to another page via ajax
body: <p>I have a simple contact form for download excel file . Main issue happen , When ajax load .I want to download excel file then redirect user to a next page.. Below is my code with dummy data.. </p>
  
  <p>Ajax code..</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "/site/ajaxexcel.php", 
      data: {'value':'send'},
      cache: false,
      success: function(html){
          location.href = '&lt;?php echo base_url()."/site/welcome.php" ?&gt;';                 
      }
  });
  </code></pre>
  
  <p>And my <code>ajaxexcel.php</code> code is:</p>
  
  <pre><code>&lt;?php 
  $content= '&lt;html xmlns:x="urn:schemas-microsoft-com:office:excel"&gt;
  &lt;head&gt;
      &lt;!--[if gte mso 9]&gt;
      &lt;xml&gt;
          &lt;x:ExcelWorkbook&gt;
              &lt;x:ExcelWorksheets&gt;
                  &lt;x:ExcelWorksheet&gt;
                      &lt;x:Name&gt;Sheet 1&lt;/x:Name&gt;
                      &lt;x:WorksheetOptions&gt;
                          &lt;x:Print&gt;
                              &lt;x:ValidPrinterInfo/&gt;
                          &lt;/x:Print&gt;
                      &lt;/x:WorksheetOptions&gt;
                  &lt;/x:ExcelWorksheet&gt;
              &lt;/x:ExcelWorksheets&gt;
          &lt;/x:ExcelWorkbook&gt;
      &lt;/xml&gt;
      &lt;![endif]--&gt;
  &lt;/head&gt;
  
  &lt;body&gt;&lt;table class="table table-condensed table-striped table-hover table-bordered pull-left" id="myTable"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;th&gt;kumar&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;th&gt;Rakesh&lt;/th&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;';
  header('Content-type: application/excel');
  header('Content-type: image/jpeg,image/gif,image/png');
  header("Content-Disposition: attachment; filename=download.xls");
  header("Pragma: ");
  header("Cache-Control: ");
  echo $content;
  ?&gt;
  </code></pre>
  
  <p>I want to just download excel file and then redirect user to a specific location.</p>
  
  <p>Also you can help me with your codeigniter code if you have done it properly..</p>