模板文字为空

I have some template literals in different jquery functions. some of them are working. But this block is not executing.

function viewUserDetails(data) { // gets integer {1,2,3,...}
    let x = ``; // ""
    let y = ``; // ""
    $.ajax({
        type : "GET",
        url : 'http://localhost/bugs_javascript/api/public/getSingleUser.php',
        data : {
            "id" : data // gets value {1,2,3,...}
        },
        dataType : 'json',
        contentType : 'application/json',
        success: function (e) {
            console.log("success: "+e); // logs the returned JSON object
            x += `<label for="title">Full Name</label>
                    <input type="text" class="form-control" 
id="updateUserName" oninput="checkName('update')"
                            value="${e.name}">
                    <span id="uNameMsg"></span>
                    <br>
                    <label for="title">Unique ID</label>
                    <input type="textarea" class="form-control" id="updateUserUnique" rows="5"
                            value="${e.nick_name}" 
oninput="checkUnique('update', ${e.nick_name})">
                    <span id="uUniqueMsg"></span>
                    <br>
                    <label for="title">Email</label>
                    <input type="text" class="form-control" 
id="updateUserEmail"
                            value="${e.email}" 
oninput="checkEmail('update', ${e.email})">
                    <span id="uEmailMsg"></span>
                    <br>
                    <button class="btn btn-success" 
id="editUserFButtton"
                            onclick="updateUser(${e.id})">Update 
Record</button>
                    <span id="updateUserBtnMsg"></span>`; // x = ""
            y = `User Registered on: ${e.registration_date}`; // y = ""
        },
        error : function (e) {
            console.log("error: "+e);
        }
    });

    $("#modalFlashContent").append(x); // "" null
    $("#modalFlashHeader").text(y); // "" null
} // Not working. Some prooblem

This should give an HTML block in x and y variable as the AJAX request is happening. But it gives null.

At the bottom of the function, x and y are going to be null because the success of your ajax call is going to return later than when you assign x and y. You need to put

$("#modalFlashContent").append(x);
$("#modalFlashHeader").text(y);

at the bottom of the success call.