AJAX / PHP的滞后问题原因

So i am trying to make an asynchronous call of a PHP script but for some reason there is an error: Maximum call stack size exceeded that is making my site lagging a LOT. There must be a loop somewhere in my code but i can't really find it. I am looking for the past 3 days and still nothing. If someone could spot anything i would be really greatfull. Thanks in advance!

PHP code:

<?php

    require_once 'li.php'; //File with the constants    

    $Username = $_POST['Username'];

    $query = "SELECT Username
                FROM user_info
                WHERE Username = ?
                LIMIT 1";

    if($stmt = $conn->prepare($query)){   //Prepares the statement!

        $stmt->bind_param('s', $Username); 
        $stmt->execute(); //Executes it!

        if($stmt->fetch()){ //Checks if the query returns anything!

            $stmt->close(); //If yes then closes the prepared statement!
            $error = "Username taken";
            echo $error;
        }   
    }
?> 

AJAX/JS code:

$(document).ready(function(){

    $('#Username').on("keyup", function(){

        $.ajax({
            type: 'POST',
            url: 'NameValidation.php', //Your required php page
            data: { Username: Username }, //pass your required data here
            async: true,
        }).done(function(response){

            if(response != ""){
                $('#UsernameLabel').html("Username Taken!");
            }
        });     
    });
});

In case you didn't understand what i want to do with this code let me explain some more. I want every time the Username input changes to search if the username already exists in the database and alert the user by changing the Label text.

PS: Dont worry about SQL injection security i'll add that later when i fix this problem! ^-^

you are not closing connection if query returns nothing, try changing the code to :

if($stmt->fetch()){ //Checks if the query returns anything!
     $error = "Username taken";
     echo $error;
}  
$stmt->close(); //close connection in any case