PHP正确处理数据的Ajax响应为空

I have a form that performs a POST call on a php file on the server; the request is processed correctly, but when I try to handle it, it is shown as a null value. Here my php fragment:

<?php
header('Access-Control-Allow-Origin: *');

require_once 'access.php';

//connection to db
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

if (mysqli_connect_errno()) { //verify connection
    echo "Error to connect to DBMS: ".mysqli_connect_error(); //notify error
    exit(); //do nothing else
}

//Take user team request
$teamchoice = $_POST['team'];

//retrieving all people of that team
$query = "SELECT * FROM pokecods WHERE team = '$teamchoice'";
$result = $mysqli->query($query);


if ($result->num_rows > 0) 
    echo json_encode($result);
else
    echo 'Oops, something went wrong';

$result->close();
$mysqli->close();
?>

The query performs correctly, because as result I have a json object (there's only one object that matches the query in the db), but when I try to handle this object, I have this result: result

here my jQuery code:

    $.post(post_url, post_data)
        .done( function(response) {
var json = JSON.parse(response);        
    console.log(json);
})
        .fail( function() {
            alert("The AJAX request failed!");
        });

what do I have to do in order to handle correctly my object?

You forgot fetch result after executing query. Fetch results using fetch_all and then pass to json_encode.

Updated code:

if ($result->num_rows > 0) {
    $records = $result->fetch_all(MYSQLI_ASSOC);
    echo json_encode($records);
} else {
    echo 'Oops, something went wrong';
}