$(document).ready(function() { // Variable to hold request var request; // recaptcha var isHuman = grecaptcha.getResponse(); // Bind to the submit event of our form $("#contact_form").submit(function(event){ // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Fire off the request to /form.php request = $.ajax({ url: "/contact.php", type: "post", data: {serializedData:serializedData, isHuman:isHuman}, success: function(data){ $('#dialog').html(data); $('#dialog').dialog({ dialogClass: "contact-dialog", height: 200, width: 350, resizable: false, draggable: false, modal: true, show: { effect: "clip", direction: "vertical", duration: 600}, hide: { effect: "clip", direction: "vertical", duration: 600 }, title: "KONTAKT", buttons: { "OK": function() { $( this ).dialog( "close" ); } } }); } }); // Prevent default posting of form event.preventDefault(); }); }); //$("#dialog").dialog("option", "title", "Loading...").dialog("open");