hey guys. can smb help me out? im trying to clean up the code so its more readable.i started with this:
function autocompleteCity() {
$( ".city-autocomplete" ).on( "input", function() {
$.ajax({
method: "POST",
url: '?m=customeradd',
data: {
search : $(this).val(),
state: $('.state-options').find(":selected").data('id-sav'),
mode : 'city'
},
success: function(data){
$('#city-autocomplate-wrapper').empty();
let result = JSON.parse( data );
let autoElem = '<div class="auto-elem">';
$.each( result, function( key, value ) {
let select = '<div class="autocompleter-elem"><span data-id="'+ value.id_reg_centras +'">' + value.name +' '+ value.short_type +'</span> </div>'
autoElem = autoElem.concat(" ", select);
});
autoElem = autoElem.concat(" ", '</div>');
$( "#city-autocomplate-wrapper" ).append( autoElem );
}
});
} );
}
and so far i have this:
function getCitiesForAutocomplete(searchValue, stateId) {
const ajaxRequest = {
method: 'POST',
url: '?m=customeradd',
data: {
search: searchValue,
state: stateId,
mode: 'city'
}
};
what to do next? id like to work on making that success function (or whatever it is) more readable. can smb help me out or give some guidance? much appreciated 😄