title: how to solve cannot read property 0 of undefined in javascript
body: <p>I have already tried many of the solutions on Stack Overflow but none of them have worked in my case. I'm just stuck on this little parsing thing in this ajax call. 
  My json looks like this:</p>
  
  <pre><code>{
    "DailyCohorts":[
      {
        "transDate":"2017-10-01",
        "newUsers":"9",
        "CustomerAddedDate":"2017-10-01",
        "UserCount":"5"
      }, 
      //...
    ]
  }
  </code></pre>
  
  <p>and this is my for loop where I'm trying to take out values </p>
  
  <pre><code> function dailyCohort(){
  
    $.ajax({
    type: "GET",
    url: "http://com/sp/cohort.php",
  
     success: function(data){    
  
        console.log("json",data);
        console.log("data length",data.length);
  
      for(i=0; i&lt; data.DailyCohorts.length; i++)
      {
         console.log(data.DailyCohorts[i].transDate);
      }
  
      }, 
       beforeSend: function() {
          $("#w-cohort-loader").show()
      },
      complete: function() {
          $("#w-cohort-loader").hide();
      },
  
      error: function(data)
      {
          console.log(data);
      } 
      }); 
  } 
  </code></pre>
  
  <p>Please help me with this, thanks in advance            </p>