title: Ajax JSON request seemingly receiving a blank response
body: <p>I am trying to update my custom shopping cart through PHP/mySQL by way of an AJAX call. I am trying to receive a response in JSON format but the PHP script seems to be returning an empty array.</p>
  
  <p>The following are the scripts:</p>
  
  <p><strong>The AJAX Part</strong></p>
  
  <pre><code>//update cart
          url_cart="http://localhost/all/anm2/cart_queries.php?id=" + id + "&amp;qty="  + qty + "&amp;ses=" + ses;
          $('#refresh_cart').css('display','block');
  
          $.ajax({ 
              type: 'GET', 
              url: url_cart, 
              dataType: 'json',
              success: function (json) { 
                  $("#cart_items").empty();
                  $.each(json.cart_items, function(i, dat) {
                      $("#cart_items").append('&lt;li&gt;' + dat.pd_name + ' ' + dat.cart_qty + ' ' + dat.pd_general_price + '&lt;/li&gt;');
                  });
                  $('#refresh_cart').css('display','none');
              }
          });
  </code></pre>
  
  <p><strong>The PHP Part</strong></p>
  
  <pre><code>&lt;?php
  
      $arr = array();
      $id=(isset($_GET['id']) &amp;&amp; $_GET['id'] != '') ? $_GET['id'] : '';
      $ses=(isset($_GET['ses']) &amp;&amp; $_GET['ses'] != '') ? $_GET['ses'] : '';
      $qty=(isset($_GET['qty']) &amp;&amp; $_GET['qty'] != '') ? $_GET['qty'] : '';
  
      mysql_query("INSERT INTO tbl_session_cart VALUES (" . $ses. ", " . $id . ", " . $qty .")");
  
      $rs = mysql_query("SELECT pd_name, pd_general_price, cart_qty, cat_id
                          FROM tbl_session_cart sc
                          LEFT JOIN tbl_product p ON sc.pd_id = p.pd_id
                          WHERE ses_id LIKE '" . $ses. "'");
  
      while($obj = mysql_fetch_object($rs)) {
          $arr[] = $obj;
      }
      echo '{"cart_items":'.json_encode($arr).'}';        
  
  ?&gt;
  </code></pre>
  
  <p>I have tested the script thoroughly and have concluded that the PHP script works well on its own and it does the necessary database update, and the AJAX script itself is working well as it is receiving a response.</p>
  
  <p>But the response the PHP script produces when called through the AJAX script is an empty array and there is no database update done. Is there some parameter that I'm missing out on the AJAX script? Or is it something else entirely?</p>
  
  <p>For reference I am including the echo done by the PHP script when I call it directly. I have checked this and its a valid JSON response:</p>
  
  <pre><code>{
      "cart_items": [
          {
              "pd_name": "Original Vanilla",
              "pd_general_price": "100.00",
              "cart_qty": "2",
              "cat_id": "1"
          },
          {
              "pd_name": "Original Vanilla",
              "pd_general_price": "100.00",
              "cart_qty": "2",
              "cat_id": "1"
          },
          {
              "pd_name": "Original Vanilla",
              "pd_general_price": "100.00",
              "cart_qty": "2",
              "cat_id": "1"
          }
      ]
  }
  </code></pre>