AJAX调用无法从PHP获取数据,显示未定义的数据

I am new to web development and this is my first question here so please don't mind my vagueness, if any.

Now, I am facing facing problem with my javascript file which is supposed to draw a line chart. Through an ajax call I am unable to fetch data from a php file which gets some variable from a html form. The problem is that I am not getting anything when I load my test.html (which includes the necessary file) not even in console.

Relevant part of my js file is here (graph.js):

$(document).ready(function(){
$.ajax({
    url : "http://localhost/series/data.php",
    type : "GET",
    dataType: "json",
    success : function(data){
        console.log(data);

        var time = [];
        var sensor1 = [];
        var sensor2 = [];
        var sensor3 = [];

        for(var i in data) {
            time.push("time " + data[i].time);
            sensor1.push(data[i].sensor1);
            sensor2.push(data[i].sensor2);
            sensor3.push(data[i].sensor3);
        }...

And this is my PHP file(data.php):

<?php
 header('Content-Type: application/json');
//connects to database
include '2connect.php';
//gets a date of which sensor data is to be displayed
if(isset($_GET['dateselector'])&&!empty($_GET['dateselector'])){
        $date=$_GET['dateselector'];
        //echo "$date";
    $query1= "SELECT `time`,`sensor1`,`sensor2`,`sensor3` FROM `$date`";

if($result = mysqli_query($con,$query1)){

        $data=array();
        while ($row = mysqli_fetch_assoc($result)) {
            $data[]=$row;
        }

        $result->close();
        $con->close();

        print json_encode($data);
    }else {
        echo"<br> failed <br>";
    }
}else {
    echo "You didn't select a date 
";
}

?>

Whenever I remove the isset check from my php code and give $date a value the code runs perfectly. Is it so that ajax doesn't fetches data from a php file which gets data (form data) from another file?

EDIT: The process is: User chooses a date from the calender (index.html) that date is sent to a php file (data.php) which displays the result in json format. Then in another browser I open a html file(test.html) which includes graph.js and graph.js should fetch data from data.php.