Uncaught TypeError: Cannot read property of null
<p>Hello im having trouble of fixing this error <code>Uncaught TypeError: Cannot read property '2' of null</code>. This is what i want to do, if i click to the day without event the <code>#myModal</code> will show but if i click the day with event the <code>#delete</code> modal will show. But my problem is when im clicking the day without event im getting an error of <code>Uncaught TypeError: Cannot read property '2' of null</code>. </p>

<p><a href="https://i.stack.imgur.com/3q5uQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3q5uQ.png" alt="enter image description here"></a>
here's the ajax </p>

<pre><code>  dayClick: function(date, allDay, jsEvent, view) {
    var datee = date.format();
                 $.ajax({
                url:'getrecords.php',
                method:'POST',
                dataType: 'json',     
                data:{
                  "filter": 1,
                  "start": datee

                },
                success:function(data){
                var date = data[2];    

                if(date == datee){
                  $('#delete').modal('show');
                }
                else{
                  $('#myModal').modal('show');
                }

                }
              });
</code></pre>

<p>here's the php </p>

<pre><code>  if(isset($_POST['filter']))
   {
        $start = $_POST['start'];
         $select = mysqli_query($con,"SELECT * FROM appointment WHERE start = '$start'");     
        $check_user = mysqli_num_rows($select);
      $array = mysqli_fetch_row($select);  
      echo json_encode($array);   
   }
</code></pre>