var url = "https://powercloudfunctions.azurewebsites.net/api/Function1?code=PoNMEUi55z3pJ/qhECxzhHt9q/KBYcJ/Rks5WUmXRudQ1qTdhjKEZw=="; $("form").on('submit', function (event) { event.preventDefault(); // grab contact form data var data = $(this).serialize(); // hide prior errors, disable inputs while we're submitting $("#contactFormError").hide(); $("#contactForm input").prop('disabled', true); // back in my day, we had to AJAX uphill both ways, in the snow, through cross-iframe scripts $.ajax({ type: "POST", url: url, data: data, dataType: "text", headers: {'Content-Type': 'application/x-www-form-urlencoded'}, success: function (respData) { // Yay, success!! $("#contact-response").html("
" + respData + "
"); }, error: function (jqXHR) { // Boo, error... $("#contactFormError").html("
Sorry, an error occurred: " + jqXHR.responseText + "
"); $("#contactFormError").show(); $("#contactForm input").prop('disabled', false); } }); });