I'm having a trouble with AJAX results. I've got results from the query from MySQL, but AJAX responded differently. I have equated the query both MySQL and AJAX. The query will only show 1 row or not at all. Could you show me where the wrong comes?
This is the query
SELECT a.id_pendaftaran, l.nama_layanan, p2.asal_perusahaan, a.status from
 antrian a JOIN pengunjung p2 ON a.id_pendaftaran = p2.id_pengunjung JOIN 
layanan l ON a.id_layanan = l.id_layanan WHERE a.id_pendaftaran = 'gmFhJd2t0N'
And then this is the AJAX
   $('.cekbutton').click(function(e){
        var id = $('#id_pendaftaran').val();
            e.preventDefault(); 
            $.ajax({
                url:"ajax.php",
                type:"GET",
                data : "id="+id,
                success : function(result) {
                    console.log(result);
                    var datanew = JSON.parse(result);
                    $('#layanan').val(datanew.layanan);
                    $('#nama_perusahaan').val(datanew.nama);
                    $('#status').val(datanew.status);
                    $('#layanan').prop('disabled', true);
                    $('#nama_perusahaan').prop('disabled', true);
                    $('#status').prop('disabled', true);
                }
            });
        });
<?php
    include "../connection.php";
    $q = mysqli_real_escape_string($koneksi, $_GET['id']);
    $query = mysqli_query($koneksi, "SELECT a.id_pendaftaran, l.nama_layanan,
 p2.asal_perusahaan, a.status from antrian a JOIN pengunjung p2 
ON a.id_pendaftaran = p2.id_pengunjung JOIN layanan l ON a.id_layanan = l.id_layanan 
WHERE a.id_pendaftaran = '".$q."'");
    if (mysqli_num_rows($query) == 1) {
        $row = mysqli_fetch_array($query);
        $nama = $row['asal_perusahaan'];
        $layanan = $row['nama_layanan'];
        $status = $row['status'];
        $myObj = array('hasil' => true, 'nama' => $nama, 'layanan' => $layanan, 'status' => $status);
    }
    else {
        $myObj = array('hasil' => false, 'nama' => "-", 'layanan' => "Belum terdaftar", 'status' => "-");
    }
    $myJSON = json_encode($myObj);
    echo $myJSON;
?>
Result from MySQL
id_pendaftaran | nama_layanan  | asal_perusahaan | status |
gmFhJd2t0N     | Certification | ABC             | Waiting |
and this from the browser console
{"hasil":false,"nama":"-","layanan":"Belum terdaftar","status":"-"}
If I changed this equation (mysqli_num_rows($query) == 1) other than this, the result would be:
{"hasil":true,"nama":null,"layanan":null,"status":null}
 
    