I'm looking to retrieve a user's avatar using their user name, retrieve it in an input field. However what I did does not work and I am not familiar with Ajax. Could someone help me and explain the procedure to me?
<input type="text" name="username" class="input" placeholder="Your username">
<img id="#result" src=""></img>
Here is my ajax
$(document).keyup(function (event) {
    $.ajax({
        url: "App/Actions/PlayerGetFigure.php",
        type: "post",
        data: {
            login: function () {
                return $(':input[name="username"]').val();
            },
        },
        success: function (data) {
            $('#result').html(data);
        }
    });
});
And here is my PHP
require '../../vendor/autoload.php';
use App\Models\UsersManager as Users;
$Users = new Users();
$username = $_POST['username'];
if (isset($username)) {
    $user = $Users->getByUsername($username);
    if ($user) {
        echo $user['avatar'];
    } else {
        return false;
    }
}
 
     
    