Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax POST - 'XMLHttpRequest.withCredentials' for synchronous requests is deprecated

What I'm trying to do should be simple.

I'm trying to post some form values to an mvc controller that returns JSON.

If I get true for success, I show one popup if I get false I show another pop-up.

But in the console I get two errors:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

browserLink:37 Setting 'XMLHttpRequest.withCredentials' for synchronous  requests is deprecated.
Navigated to http://aso.local/

and the page just reloads.

Heres my code:

    $('#mail-message-btn').click(function () {
    if ($("form")[0].checkValidity()) {
        var formParams = $('#contact-form').serialize();
        $.post('/umbraco/surface/Contact/ContactForm', formParams, function (data) {
            processData(data);
        });
    }
});


function processData(data) {
    $('#mail-failure').hide();
    $('#invalid-email').hide();
    $('#empty-field').hide();
    $('#mail-success').hide();
    if (data.success == 'True') {
        $('#mail-message-header').toggleClass('mail-message-error', false);
        $('#mail-message-header').toggleClass('mail-message-success', true);
        $('#mail-success').show();
        $('#mail-message').show();

        alert("true");
    } else if (data.success == 'False') {

        alert("false");
        $('#mail-message-header').toggleClass('mail-message-error', true);
        $('#mail-message-header').toggleClass('mail-message-success', false);
        $('#mail-failure').show();
        $('#mail-message').show();

    }
}

I put test alert windows in to make sure I am getting in to the right if blocks and when I do this it works! (the pop up windows shows) but as soon as I click the ok in the alert box my pop up window vanishes!

So Frustrating, I have also tried $.Ajax with the same result!

Help?

like image 355
Ayo Adesina Avatar asked Dec 15 '22 14:12

Ayo Adesina


1 Answers

The error you are seeing comes from Visual Studio's BrowserLink. Possibly try disabling BrowserLink and see if you still get the error?

http://www.poconosystems.com/software-development/how-to-disable-browser-link-in-visual-studio-2013/

like image 131
12c4IT Avatar answered Feb 15 '23 23:02

12c4IT