title: I send variables to export.php through Ajax, but it is not received in export page
body: <p>I send variables to export.php through Ajax, but it is not received in export page. it shows</p>
  
  <blockquote>
    <p>Undefined index: name in D:\xampp\htdocs\Vergands - Admin1\export.php on line 2</p>
  </blockquote>
  
  <p>customer.php</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          $(".export_button").click(function(){
             var tableName = $("#tableName").val();
  
             $.ajax({
                  method:"post",
                  url:"export.php",
                  data:{name:tableName}
  
                 });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>export.php  /*its working fine when i run export.php alone and excel file getting downloaded( using 
  this function export('customer_profile'); 
  customer_profile is table name 
   */</p>
  
  <pre><code>  &lt;?php
  
      $tableName_final = $_POST["name"];
  
       function export($tableName_final){
  
  
              $servername = "localhost";
              $username = "root";
              $password = "";
              $dbname = "admin_vergands";
              //mysql and db connection
  
              $con = new mysqli($servername, $username, $password, $dbname);
  
              if ($con-&gt;connect_error) {  //error check
                  die("Connection failed: " . $con-&gt;connect_error);
              }
              else
              {
              echo "connection failed";
              }
  
  
  
              $DB_TBLName = $tableName; 
              $filename = "excelfilename";  //your_file_name
              $file_ending = "xls";   //file_extention
  
              header("Content-Type: application/xls");    
              header("Content-Disposition: attachment; filename=$filename.xls");  
              header("Pragma: no-cache"); 
              header("Expires: 0");
  
              $sep = "\t";
  
              $sql="SELECT * FROM $DB_TBLName"; 
              $resultt = $con-&gt;query($sql);
              while ($property = mysqli_fetch_field($resultt)) { //fetch table field name
                  echo $property-&gt;name."\t";
              }
  
              print("\n");    
  
              while($row = mysqli_fetch_row($resultt))  //fetch_table_data
              {
                  $schema_insert = "";
                  for($j=0; $j&lt; mysqli_num_fields($resultt);$j++)
                  {
                      if(!isset($row[$j]))
                          $schema_insert .= "NULL".$sep;
                      elseif ($row[$j] != "")
                          $schema_insert .= "$row[$j]".$sep;
                      else
                          $schema_insert .= "".$sep;
                  }
                  $schema_insert = str_replace($sep."$", "", $schema_insert);
                  $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
                  $schema_insert .= "\t";
                  print(trim($schema_insert));
                  print "\n";
              }
          }
      export($tableName_final);
  
      ?&gt;
  </code></pre>