$.ajax – TypeError: Cannot read properties of undefined (reading ‘open’)

I want to use $.ajax on my web page but it keeps giving me the following error in console:

TypeError: Cannot read properties of undefined (reading ‘open’)

If I use the $.post, it works fine, but for $.ajax it keeps giving me the error above.

My $.ajax call:

$.ajax({
    type: "POST",
    url: "http://localhost/users/ajax/add_user.php",
    dataType: "application/x-www-form-urlencoded; charset=UTF-8",
    data: {
        name: "James",
        note: "New user"
    },
    xhr: function(xhr){
        console.log("XHR");
    },
    success: function(xhr){
        console.log("SUCCESS");
    },
    error: function(xhr){
        console.log(xhr.statusText);
    },
    complete: function(xhr){
        console.log("COMPLETE");
    },
});