title: AJAX returns Undefined error when displaying an Array of objects using jQuery in PHP on console
body: <p>I am trying to read a JSON through jQuery and AJAX and some objects like the <code>SUM(amountbet) object</code> in the Array are returning as <code>&quot;undefined&quot;</code>on console.</p>
  <p><a href="https://i.stack.imgur.com/pMUqc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pMUqc.png" alt="the SUM(amountbet) object is returning undefined on console" /></a></p>
  <p>The above image shows the <code>SUM(amountbet) object</code> as undefined on the console.</p>
  <p><a href="https://i.stack.imgur.com/ZgPRJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZgPRJ.png" alt="Here is the Array of objects that i am displaying on console as request:" /></a></p>
  <p>But when I am trying to access the &quot;SUM(amountbet)&quot; object it returns me &quot;undefined&quot; on console but when returning the horsename object the value is displayed perfectly. What am i doing wrong here?</p>
  <p>Here is my AJAX, jQuery code where i am trying to display each objects in that Array comming from an SQL Query:</p>
  <pre><code>$(document).ready(function(){
  
  var racenumberr = $(this).attr(&quot;RaceNumber&quot;);
  
  var data = new FormData();
  
  data.append(&quot;RaceNumber&quot;, racenumberr);
  
  $.ajax({
  
      url:&quot;ajax/horses.ajax.php&quot;, 
      method: &quot;POST&quot;, 
      data: data,
      cache: false,
      contentType: false,
      processData: false,
      dataType: &quot;json&quot;,             
      success: function(response) {
  
          console.log(&quot;Horse Information Displayed In Array&quot;,response);
  
          var len = response.length;
          for (var i = 0; i &lt; len; i++) {
  
              var horsename = response[i].horsename;
              var totalbetting = response[i].totalbetting;
              var totalpayout = response[i].payout;
  
              console.log(&quot;Horse Names&quot;,horsename);
              console.log(&quot;Horse Payouts&quot;,totalbetting); // &lt;-- object is displayed undefined on console
  
          }
  
      }
  })
  
  });
  </code></pre>