$(function() {
let fadeSpeed = 200, // Fade Animation Speed
ajaxContainerSelector = '.ajax-container', // CSS Selector of Ajax Container
ajaxItemSelector = '.ajax-item', // CSS Selector of Ajax Item
ajaxFormSelector = '.ajax-form'; // CSS Selector of Ajax Filter Form
$('' + ajaxFormSelector + '').submit(function() {
return false;
});
function ajaxMainFunction() {
let $that = $(this);
$.ajax({
data: $that.parents(ajaxFormSelector).serialize()
}).done(function(response) {
let $response = $(response);
$that.parents(ajaxContainerSelector).fadeOut(fadeSpeed);
setTimeout(function() {
$that.parents(ajaxContainerSelector).html($response.find(ajaxContainerSelector).html()).fadeIn(fadeSpeed);
}, fadeSpeed);
});
}
$('' + ajaxFormSelector + ' input').change(function() {
ajaxMainFunction.call(this);
});
$('' + ajaxFormSelector + ' select').change(function() {
ajaxMainFunction.call(this);
});
});