title: How to pass array value with an XMLHttpRequest
body: <p>i need to send array parameter or value using XMLHttpRequest</p>
  
  <p>Something like this</p>
  
  <pre><code>$(document).on('click','.save_edit_class',function(){
  
  var crit_name_text = $('#crit_name_text').val();
  var crit_desc = $('#crit_desc_text').val();
  var sub_crit_arr = [];
  $('.sub_crit_text').each(function(k , v){
      sub_crit_arr[k] = $(v).val();
  
  });
  
  var http = new XMLHttpRequest();
  var url = "xml_remove_criteria.php";
  var params =  "crit_name_text="+crit_name_text+"&amp;crit_desc="+crit_desc+"&amp;sub_crit_arr[]="+sub_crit_arr+"";
  
  http.open("GET", url+"?"+params, true);
  http.onreadystatechange = function(){//Call a function when the state changes.
      if(http.readyState == 4 &amp;&amp; http.status == 200){
          alert(http.responseText);
      }
  }
  http.send(null);
  
  });
  </code></pre>
  
  <p>How can i send  the sub_crit_arr(the array) variable to my xml page as array? I'm trying to send using that, but i got an error invalid argument supplied foreach.</p>
  
  <p>This is my xml page..</p>
  
  <pre><code>&lt;?php
  session_start();
  include("../global.php");
  header('Content-Type: text/xml');
  echo '&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;';
  
  echo '&lt;response&gt;';
      if(isset($_GET['crit_name_text'])){
         $criteria_name = $_GET['crit_name_text'];
         echo $criteria_name;//testing
  
          if(isset($_GET['crit_desc'])){
              $crit_desc = $_GET['crit_desc'];
              echo $crit_desc;//testing
          }
  
  
      if(isset($_GET['sub_crit_arr'])){
          $sub_crit_arr = $_GET['sub_crit_arr'];
          $sub_crit_arrs = array();
          $count = 0;
          foreach ($sub_crit_arr as $value) {
              $sub_crit_arr[$count] = $value;
              echo $sub_crit_arr[$count]." - value&lt;br/&gt;";//testing
              $count++;
          }
      }
  
     }
     echo '&lt;/response&gt;';
  </code></pre>
  
  <p>?></p>