title: Laravel ajax not returning data
body: <p>I am having trouble retrieving data from Controller using ajax
  this is my code</p>
  
  <p>the trigger</p>
  
  <pre><code>&lt;select id="course_select" name="course_select" class="form-control" required autofocus value="{{old('course_select')}}" onchange="getCourse()"&gt;
  </code></pre>
  
  <p>The my ajax section</p>
  
  <pre><code>function getCourse(){
    var id=document.getElementById('course_select').value;
    alert(id);
    $.ajax({
      type:'get',
      url:'getCourseLessons/'+id,
      datatype:'json',
      success:function(data){
        console.log(data);
        alert(data.lessons);
      }
    });
  }
  </code></pre>
  
  <p>and my controller</p>
  
  <pre><code>public function getCourseLessons($id){
        $lessons = DB::table('lessons')-&gt;select('id','Lesson_name')-&gt;where('course_id','=',$id)-&gt;get();
        return response()-&gt;json(array('lessons'=&gt;$lessons));
  }
  </code></pre>
  
  <p>Results console.log(data)</p>
  
  <pre><code>console.log(data)
  ReferenceError: data is not defined[Learn More]
  </code></pre>
  
  <p>My Routes.</p>
  
  <pre><code>Route::get('/getcourselessons/{id}','AdminController@getCourseLessons');
  </code></pre>
  
  <p>I will appreciate all the help i can get.</p>