title: How to pass an array with ajax
body: <p>I'm trying to pass an array with ajax with a post to a php page.</p>
  
  <p>My code js is : </p>
  
  <pre><code> function funzione5(){ 
       var aux2=document.getElementById('f1').value; 
  
  $.ajax({type: "POST",
              url: "AddMeeting.php", 
                  data: {
                      'aux':aux,
                      'aux2':aux2,
                      'k':k
  
                  }, 
                      success: {function(data){
                          console.log(data);
                      }
  
                                   },
          error: {function(){alert("Error");}} 
              }); 
   $('#modalMeeting').modal('hide');
   }
  </code></pre>
  
  <p>and the php page is : </p>
  
  <pre><code>&lt;?php
   if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')
   {
     header("Location: Meetings.php");
     exit();
   }
  
   if(!isset($_COOKIE["id"]))
   {
     $json_data = array(
  'draw'            =&gt; 0,
  'recordsTotal'    =&gt; 0,
  'recordsFiltered' =&gt; 0,
  'data'            =&gt; [],
  'error'           =&gt; 'Laravel Error Handler',
            );
                    $json = json_encode($json_data);
               echo $json;
          exit();
   }   
  
  
  
   include("DB.php"); //dati configurazione del database
  
  
  
  $cont = mysqli_real_escape_string($connessione, $_POST["k"]);
                    $title = mysqli_real_escape_string($connessione, 
   $_POST["aux[0]"]);
               $date = mysqli_real_escape_string($connessione, 
  $_POST["aux[1]"]);
          $place = mysqli_real_escape_string($connessione, $_POST["aux[2]"]);
     $topic = mysqli_real_escape_string($connessione, $_POST["aux[3]"]);
       $lat = mysqli_real_escape_string($connessione, $_POST["aux[4]"]);
     $lng = mysqli_real_escape_string($connessione, $_POST["aux[5]"]);
  
  for($i=6;$i&lt;$cont;$i++) 
   {  $part_id+$i = mysqli_real_escape_string($connessione, 
  $_POST["aux[".$i."]"]);  }
  
       $card_id = mysqli_real_escape_string($connessione, $_POST["aux2"]);
  $id2=$_COOKIE['id'];
       echo mysqli_error($connessione);
  
  
        $sql1=mysqli_query($connessione,"insert into meeting 
   (card_id,user_id,title,place,date,topic,lat,lng) values 
   ('$card_id','$id2','$title','$place','$date','$topic','$lat','$lng');");
  
  
  
     echo mysqli_error($connessione);
     $json_data = array(
  
                                  "result" =&gt; 1
                           );
  $json = json_encode($json_data);
  echo $json;
  
  
  
   ?&gt;
  </code></pre>
  
  <p>Is it correct to pass an array in this way? I checked that in the function "funzione5" the values of the array are set correctly. What could be the problem? Can you explain me how to pass the array? I searched on the web but i didn't find anything.</p>