Javascript - 未捕获的ReferenceError:未定义azZkVUpgbG,而控制台成功打印我的数据

I have the follwing JS function:

function setOptions(fullName, userID, qObjID) {
    document.getElementById("reportUserButt").innerHTML = "<a id='reportUserButt' href='javascript:reportUser(" + userID + ");'> <h5>Report @" + fullName + "<span style='opacity: 0.5'> -- " + userID + "</h5></a>";
}

which calls this func:

// REPORT A USER ---------------------------------------
function reportUser(userID) {
    $('#optionsModal').modal('hide');

    console.log("userID: " + userID);

    // Show loading modal
    document.getElementById("loadingText").innerHTML = "Reporting User, please wait...";
    $('#loadingModal').modal('show');


    $.ajax({
            url:"report-user.php?userID=" + userID, 
            type: "GET", 

            success:function(data) {
                var results = data.replace(/\s+/, ""); //remove any trailing white spaces from returned string
                console.debug(results);

                $('#loadingModal').modal('hide');

                alert("Thanks for reporting this user! We will check it out within 24h.");

                // Reload page
                setTimeout(function(){
                    location.reload();
                }, 100);

            // error
            }, error: function (e) { alert(e);}
        });
}

So I'm sure that my reportUserButt is correct because it shows me the "userID" variable in my php page, but the error I get when i click that href is:

Uncaught ReferenceError: azZkVUpgbG is not defined

azZkVUpgbG is the userID I need, so what am I doing wrong?

Userid azZkVUpgbG is a string, when you pass it to a function:

href='javascript:reportUser(" + userID + ")';

the code becomes:

href='javascript:reportUser(azZkVUpgbG)';

So, as you can see, you call reportUser with argument azZkVUpgbG which is not string.

So, the solution is to add quotes:

href='javascript:reportUser(\"" + userID + "\");'

Now, your code becomes

href='javascript:reportUser("azZkVUpgbG");'

and you pass a string to a function.