1$(function() { 2 3 // Get the form. 4 var form = $('#contact-form'); 5 6 // Get the messages div. 7 var formMessages = $('.ajax-response'); 8 9 // Set up an event listener for the contact form. 10 $(form).submit(function(e) { 11 // Stop the browser from submitting the form. 12 e.preventDefault(); 13 14 // Serialize the form data. 15 var formData = $(form).serialize(); 16 17 // Submit the form using AJAX. 18 $.ajax({ 19 type: 'POST', 20 url: $(form).attr('action'), 21 data: formData 22 }) 23 .done(function(response) { 24 // Make sure that the formMessages div has the 'success' class. 25 $(formMessages).removeClass('error'); 26 $(formMessages).addClass('success'); 27 28 // Set the message text. 29 $(formMessages).text(response); 30 31 // Clear the form. 32 $('#contact-form input,#contact-form textarea').val(''); 33 }) 34 .fail(function(data) { 35 // Make sure that the formMessages div has the 'error' class. 36 $(formMessages).removeClass('success'); 37 $(formMessages).addClass('error'); 38 39 // Set the message text. 40 if (data.responseText !== '') { 41 $(formMessages).text(data.responseText); 42 } else { 43 $(formMessages).text('Oops! An error occured and your message could not be sent.'); 44 } 45 }); 46 }); 47 48});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.