title: Ajax Uncaught TypeError: Cannot read property 'xxx' of undefined
body: <p>Hello before i am currently facing an issue where im getting lots of Ajax Uncaught TypeError: Cannot read property 'xxx' of undefined.</p>
  
  <p>here is my ajax call : </p>
  
  <pre><code>endpoint = 'api/chart/data'
  $.ajax({
    type: "GET",
    url: endpoint,    
    success: function(data){
      window.conversion_label = data.conversion_datarsion_label
      window.conversion_data= data.conversion_data
      window.profit_data_per_project= data.profit_data_per_project
      window.project_complete_date = data.sales_project_time
  
  
  
  //revi_sum is the monthly sum of the rev
      window.revi_sum = []
      window.revi_month = []
  //revi_month is the month of which the rev are made
      window.sales_revi = data.sales_rev_per_month
      for(i=0 ; i &lt;= sales_revi.length  ; i++){
          revi_sum.push(sales_revi[i].sum)
          revi_month.push(moment().month(sales_revi[i].month - 1).format("MMMM"))}
  
      console.log(sales_revi)
      console.log(revi_month)
      console.log(revi_sum)
  
  //this is the monthly quota 
      window.sales_revi_quota = []
      window.sales_revi_quota_month = []
      window.sales_quota = data.sales_rev_quota
      for(i=0 ; i &lt; sales_quota.length ; i++){
          sales_revi_quota.push(sales_quota[i].sales_rev_quota)
          sales_revi_quota_month.push(moment().month(sales_quota[i].sales_rev_quota_date).format("MMMM"))}
  
  //this is the dates of which each project created. use for tracking profit 
      window.sales_project_date = []
      for(i=0 ; i &lt; project_complete_date.length ; i++){
          sales_project_date.push(new Date(project_complete_date[i]))}
  
  
  
      createChart()
  
  
  },
  error: function(error_data){
  console.log('error')
  console.log(error_data)
  }
  })
  </code></pre>
  
  <p>i do not understand why im getting this issue when im doing my loops within the ajax call itself , anyhelp will be greatly appreciated!</p>