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?
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With