I have an ajax function and thought it would be nice to include a little ajax-spinner to tell the enduser something is actually happening. This is my current jQuery function:
$('#contact-form').submit(function(e)
{
    e.preventDefault();
    let overlay = $('#overlay'),
        loader = $('#loader-popup');
    console.log(overlay);
    console.log(loader);
    console.log('===================');
    //show overlay
    overlay.removeClass('hidden');
    loader.removeClass('hidden');
    console.log(overlay);
    console.log(loader);
    let formData = new FormData($(this)[0]),
        params = [];
    $.ajax({
        data: formData,
        type: 'post',
        url: '/pages/contact-us/action/send.php',
        cache: false,
        contentType: false,
        processData: false,
        success: function(res)
        {
            if (res == 1) {
                params['type'] = 1;
                params['msg'] = 'We will be with you as soon as we can!'
            } else {
                try {
                    res = $.parseJSON(res);
                    let data = [];
                    $.each(res, function(key, value) {data.push(value)});
                    params['type'] = 2;
                    params['msg'] = data.join('<br />')
                } catch(e) {
                    console.log(e);
                    alert('Huh. that\'s weird, something went wrong! Please try again');
                    //cause syntax error to stop script working
                    die()
                }
            }
            validator.displayAlert(params['type'], params['msg'])
        },
        error: function(res)
        {
            console.log(res);
            alert('Don\'t worry.. it\'s not you, it\'s us.')
        }
    });
    //hide overlay
    overlay.addClass('hidden');
    loader.addClass('hidden');
});
But weirdly the overlay doesn't show, nor does the loader. What makes this hard to kinda debug and fathom is the console.log output.
first console.log(overlay)
Object [ div#overlay.hidden ]second console.log(loader)
Object [ div#loader-popup.hidden ]third console.log(overlay)
Object [ div#overlay ]fourth console.log(loader)
Object [ div#loader-popup ]
So I can see that my .removeClass() function is working, however, inspecting my page once the form is being submitted shows the elements with the hidden class. If I manually remove that hidden class in the inspector tab then everything shows, so I know it's not a CSS issue.
You can see this happen on a much simpler scale here
I've also tried with .toggle() with no avail.
How do I even begin to debug something that seems to work behind-the-scenes but, not on screen?
 
     
    