title: Create and Download txt file using JQuery and PHP
body: <p>I want to make an AJAX call to PHP function that creates a txt file and download it.</p>
  
  <pre><code> if (isset($_POST["download_file"]))
  {
      $filename = "sequence.txt";
      $f = fopen($filename, 'w');
      $content="q";
      fwrite($f, $content);
      fclose($f);
      header("Cache-Control: public");
      header("Content-Description: File Transfer");
      header("Content-Length: ". filesize("$filename").";");
      header("Content-Disposition: attachment; filename=$filename");
      header("Content-Type: application/octet-stream; "); 
      header("Content-Transfer-Encoding: binary");
      readfile($filename);
  }
  </code></pre>
  
  <p>This is my PHP code and here is AJAX code</p>
  
  <pre><code>$.ajax(
  {
          url:"./apis/download_seq.php",
          data:{download_file:"true",sequence:seq},
          type: 'POST',
          success:function(data){
          }
  });
  </code></pre>
  
  <p>And this is AJAX call. Problem is that my current code saves file on server. Like it create sequence.txt file in directory where my PHP file is located.
  I want to download it to client side i.e. to my browser.</p>