1jQuery(document).ready(function($) { 2 //submit search form 3 $('form.prsearch').on('submit', function(e) { 4 e.preventDefault(); 5 e.stopImmediatePropagation(); 6 var $form = $(this).closest('form'); 7 $.post($form.attr('action'), $form.serialize(), function(data) { 8 if (data.error == true) { 9 //show error message to user 10 alert(data.content); 11 } else if (data.error == false) { 12 //leave the search form and navigation - replace only the main content 13 $('.catalog-wrap').replaceWith(data.content); 14 } else { 15 alert('Uh-oh. Something went wrong.') 16 } 17 }, 'json'); 18 return false; 19 }); 20}); 21 22jQuery(document).on('submit','form.prsearch',function(e){ 23 e.preventDefault(); 24 var $form = jQuery(this).closest('form'); 25 jQuery.post($form.attr('action'), $form.serialize(), function(data) { 26 if (data.error == true) { 27 //show error message to user 28 alert(data.content); 29 } else if (data.error == false) { 30 //leave the search form and navigation - replace only the main content 31 jQuery('.catalog-wrap').replaceWith(data.content); 32 } else { 33 alert('Uh-oh. Something went wrong.') 34 } 35 }, 'json'); 36 return false; 37}); 38 39// URL Search 40var getUrlParameter = function getUrlParameter(sParam) { 41 var sPageURL = window.location.search.substring(1), 42 sURLVariables = sPageURL.split('&'), 43 sParameterName, 44 i; 45 for (i = 0; i < sURLVariables.length; i++) { 46 sParameterName = sURLVariables[i].split('='); 47 if (sParameterName[0] === sParam) { 48 return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); 49 } 50 } 51 return false; 52}; 53jQuery(function(){ 54var searchTerm = getUrlParameter('search'); 55 if (searchTerm) { 56 jQuery.post('/wp-admin/admin-ajax.php', {action: 'search_action', search: searchTerm}, function(data) { 57 if (data.error == true) { 58 //show error message to user 59 alert(data.content); 60 } else if (data.error == false) { 61 //leave the search form and navigation - replace only the main content 62 jQuery('.catalog-wrap').replaceWith(data.content); 63 } else { 64 alert('Uh-oh. Something went wrong.') 65 } 66 }, 'json'); 67} 68}); 69 70//add to cart 71jQuery(document).on('submit','form#form1',function(e){ 72 e.preventDefault(); 73 var $form = jQuery(this).closest('form'); 74 jQuery.post($form.attr('action'), $form.serialize(), function(data) { 75 if (data.error == true) { 76 //show error message to user 77 alert(data.content); 78 } else if (data.error == false) { 79 //alert(JSON.stringify(data.content)); 80 if (data.cartURL) { 81 window.location.replace('/' + data.cartURL); 82 } 83 } else { 84 alert('Uh-oh. Something went wrong.') 85 } 86 }, 'json'); 87 return false; 88}); 89 90//update cart quantity 91jQuery(document).on('submit','form#revieworder',function(e){ 92 e.preventDefault(); 93 var $form = jQuery(this).closest('form'); 94 jQuery.post($form.attr('action'), $form.serialize(), function(data) { 95 if (data.error == true) { 96 //show error message to user 97 alert(data.content); 98 } else if (data.error == false) { 99 //alert(JSON.stringify(data.content)); 100 if (data.cartURL) { 101 window.location.replace('/' + data.cartURL); 102 } 103 } else { 104 alert('Uh-oh. Something went wrong.') 105 } 106 }, 'json'); 107 return false; 108}); 109 110//customer form checkout 111jQuery(document).on('submit','form[name="customerform"]',function(e){ 112 e.preventDefault(); 113 var $form = jQuery(this).closest('form'); 114 jQuery.post($form.attr('action'), $form.serialize(), function(data) { 115 if (data.error == true) { 116 //show error message to user 117 alert(data.content); 118 } else if (data.error == false) { 119 //alert(JSON.stringify(data.content)); 120 //jQuery('.catalog-wrap').replaceWith(data.content); 121 window.location.replace("/quote-submitted/"); 122 } else { 123 alert('Uh-oh. Something went wrong.') 124 } 125 }, 'json'); 126 return false; 127}); 128
129//https://www.tothenew.com/blog/jquery-event-binding-on-dynamically-created-content/ 130//Make sure the to bind the dynamically created contnet since its not loaded on page load.
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.