1/* 2* 3* Contact JS 4* @DynamicLayers 5*/ 6$(function() { 7 // Get the form. 8 var form = $('#book-taxi-ride'); 9 10 // Get the messages div. 11 var formMessages = $('#form-messages'); 12 13 // Set up an event listener for the contact form. 14 $(form).submit(function(event) { 15 // Stop the browser from submitting the form. 16 event.preventDefault(); 17 18 // Serialize the form data. 19 var formData = $(form).serialize(); 20 // Submit the form using AJAX. 21 $.ajax({ 22 type: 'POST', 23 url: $(form).attr('action'), 24 data: formData 25 }) 26 .done(function(response) { 27 // Make sure that the formMessages div has the 'success' class. 28 $(formMessages).removeClass('alert-danger'); 29 $(formMessages).addClass('alert-success'); 30 31 // Set the message text. 32 $(formMessages).text(response); 33 34 // Clear the form. 35 $('#full-name').val(''); 36 $('#email').val(''); 37 $('#package-type').val(''); 38 $('#passengers').val(''); 39 $('#start-dest').val(''); 40 $('#end-dest').val(''); 41 $('#ride-date').val(''); 42 $('#ride-time').val(''); 43 }) 44 .fail(function(data) { 45 // Make sure that the formMessages div has the 'error' class. 46 $(formMessages).removeClass('alert-success'); 47 $(formMessages).addClass('alert-danger'); 48 49 // Set the message text. 50 if (data.responseText !== '') { 51 $(formMessages).text(data.responseText); 52 } else { 53 $(formMessages).text('Oops! An error occured and your message could not be sent.'); 54 } 55 }); 56 57 }); 58 59});
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.