if (typeof(jQuery) != 'undefined') { jQuery(document).ready(function() { jQuery('#filter_dep').autocomplete({ minLength: 2, // supression des messages messages: { noResults: '', results: function() {} }, source: function(request, response) { // return false; jQuery.ajax({ url: 'https://www.logirem.fr/wp-content/themes/logirem/ajax/autocomplete_offre.php', dataType: 'json', type: 'POST', data: { keyword: request.term, type: 'depville' }, success: function(data) { // console.log(data); response(jQuery.map(data, function(item) { return { label: item.label, value: item.label, // EDIT // id: item.id, // type: item.type } })); }, }); } }); jQuery('#filter_dep').on('autocompleteselect', function(event, ui) { jQuery('#filter_dep').val(ui.item.label); jQuery('#form_filter_offres').submit(); }); jQuery('#filter_residence').autocomplete({ minLength: 2, // supression des messages messages: { noResults: '', results: function() {} }, source: function(request, response) { // return false; jQuery.ajax({ url: 'https://www.logirem.fr/wp-content/themes/logirem/ajax/autocomplete_offre.php', dataType: 'json', type: 'POST', data: { keyword: request.term, type: 'residence' }, success: function(data) { // console.log(data); response(jQuery.map(data, function(item) { return { label: item.label, value: item.label, // EDIT // id: item.id, // type: item.type } })); }, }); } }); jQuery('#filter_residence').on('autocompleteselect', function(event, ui) { jQuery('#filter_residence').val(ui.item.label); jQuery('#form_filter_offres').submit(); }); jQuery('#filter_type').on('change', function() { jQuery('#form_filter_offres').submit(); }); }); }