title: AJAX Call to SQL Query
body: <p>I am using the following accordian to display two the result different queries: the accordian displays one row from a query and Im using an AJAX call to a second query to populate the the accordian content area. Here is my code and question:</p>
  
  <p>Im getting the following error:</p>
  
  <p><strong>Error: [object XMLHttpRequest]</strong></p>
  
  <p>Here is my code:</p>
  
  <p><strong>Accordian</strong></p>
  
  <pre><code>&lt;div class="wrapper" &gt;
     &lt;div class="accButton" id="&lt;?php echo $name;  ?&gt;"&gt; //this value comes from the query and is passed to the AJAX call
     &lt;span class="namecustcoltype"&gt;&lt;?php echo $record;  ?&gt;&lt;/span&gt;
     &lt;span class="namecusttype"&gt;&lt;?php echo $name;  ?&gt;&lt;/span&gt;
         //Accordian content area- This div accepts the return from the AJAC call
         &lt;div class="accContent" id="output_element"&gt;   
         &lt;/div&gt;
  &lt;/div&gt; //closing div for accordian button
  </code></pre>
  
  <p><strong>AJAX Call</strong></p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
  $('.accButton').click(function() {
  var element = $(this);
  var del_id2 = element.attr("id");
   $.ajax({
     type: "POST",
     url: "item_view.php",
     //data: info,
     data: {id2:del_id2},
     success: function(response){
        $("#output_element").html(response);
     },
                error: function(msg){
                  alert("Error: "+msg);
              }
  
  });
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>item_view.php</strong></p>
  
  <pre><code>&lt;?php
  
  include('db.php');
  $id = $_POST['id2'] ;
  $name = $_POST['order_id'] ;
  $sql = "SELECT * FROM mgap_orders WHERE mgap_ska_id = '$id' GROUP BY mgap_item_description LIMIT 5";
  $stmt = $pdo-&gt;prepare($sql); 
  $items = array();
  $stmt-&gt;execute(array(':id' =&gt; '$id'));
  
      while($row_cat_sub = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
      {
      $items['item']=$row_cat_sub['mgap_item_description'];
      $items['item_num']=$row_cat_sub['mgap_item_number'];
      $items['item_type']=$row_cat_sub['mgap_item_type'];
      $items['item_cat']=$row_cat_sub['mgap_item_catalog_number'];
      $items['item_ven']=$row_cat_sub['mgap_item_vendor'];
      $items['item_pur']=$row_cat_sub['mgap_item_percent_purchased'];
      $items['item_sales']=$row_cat_sub['mgap_item_sales'];
      }
  
      foreach($items as $item) {
      ?&gt;          
        &lt;span class="namecustcoltype"&gt;&lt;?php echo $item;  ?&gt;&lt;/span&gt;
        &lt;span class="namecusttype"&gt;&lt;?php echo $item_num;  ?&gt;&lt;/span&gt;
        &lt;span class="growthcust"&gt;$&lt;?php echo $item_type;  ?&gt;&lt;/span&gt;
        &lt;span class="namecustcoltype"&gt;&lt;?php echo $item_cat;  ?&gt;&lt;/span&gt;
        &lt;span class="namecusttype"&gt;&lt;?php echo $item_ven;  ?&gt;&lt;/span&gt;
        &lt;span class="growthcust"&gt;$&lt;?php echo $item_pur;  ?&gt;&lt;/span&gt;
        &lt;span class="growthcust"&gt;$&lt;?php echo $item_sales;  ?&gt;&lt;/span&gt;                
      &lt;?php
  }
              ?&gt;
  </code></pre>