JSON的成功并未触发

I am having trouble with my JSON payload. The success function does not fire.

Thanks in advance for any help that can be provided. JLS

I get the value in the console so I know the query works okay but it is not in a key/value pair it just echos "VALUE" and does not triggers success.

//JS file ***UPDATED***

    $(document).ready(function(){
// code to get all records from table via select box
        $("#school").change(function() {
            var id = $(this).find(":selected").val();
            var dataString = 'school='+ id;
            $.ajax({
                url: 'cif_submit.php',
                dataType: "json",
                data: dataString,
                cache: false,
                success: function(data) {
                    if(data) {
                        alert(data);
                    }
                }
            });
        })
    });
//Here is the php  ***UPDATED***

if($_REQUEST['school']) {

$stmt = $conn->prepare("SELECT streetname FROM schoolinfo WHERE fullschoolname = :schoolname");
$stmt->execute (array(':schoolname' =>$_REQUEST['school']));

while($mydata = $stmt->fetch()) {   

    echo json_encode($mydata);  
} }
}

The JSON RESPONSE is:
{"streetname":"Colbeck Road, PO Bag 7200","0":"Colbeck Road, PO Bag 7200"}

I think changing the schooldata to data will fix the issue.

Don't forget that change() event gets called when you unfocus the input. https://api.jquery.com/change/

Tried with this code and worked perfectly.

JS

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
</head>
<body>
<input id="school" type="text">
<script>
    $(document).ready(function(){
// code to get all records from table via select box
        $("#school").change(function() {
            var id = $(this).find(":selected").val();
            var dataString = 'school='+ id;
            $.ajax({
                url: 'a.php',
                dataType: "json",
                data: dataString,
                cache: false,
                success: function(schooldata) {
                    if(schooldata) {
                        alert('success');
//$("#streetname").text(schooldata.streetname);  TRIED THIS NO JOY
//$("#streetname").hide(); TRIED THIS NO JOY
                    }
                }
            });
        })
    });
</script>
</body>
</html>

PHP

if($_REQUEST['school']) {
    $datas = array();
    $datas[] = array('streetname' => 'test');
    foreach ($datas as $data) {
        $data = $data['streetname'];
        //$streetname = trim(json_encode($data), '"');
        //echo json_encode($data);
        echo json_encode($data, true);
    }
}

Alert