Somehow this api call only triggers success when I leave an alert at the page, any ideas?

```html
<button class="login100-form-btn" onclick="CheckUser();">Entrar</button>

```

```js
function CheckUser() {
    const result = Auth();

    alert();
}

```

```
function Auth() {
    var data = { "Login": $("#txtLogin").val(), "Password": $("#txtPassword").val() }

    $.ajax({
        type: "POST",
        url: 'http://localhost/myAPI/auth/UserAuthenticated',
        contentType: "application/json",
        data: JSON.stringify(data),
        success: function (response) {
            console.error(response);
            if (response === "200") {
                window.location.href = "http://localhost/mySite/Home";
            }
        }        
    });
}

```