$(document).on('click','.edit', function(e) { const form = { id : $(this).data('id') } save(form, "{{ route('find-address-route') }}", "{{ csrf_token() }}") .then((res) => { $("#method").val('PUT'); //for now i'm using this but only country set selected, other's not. $("#country").val(res.data.country) $("#state").val(res.data.state) $("#city").val(res.data.city) $("#district").val(res.data.district) $("#sub_district").val(res.data.sub_district) //show modal $("#modalForm").modal('show'); }) .catch((err) => { if(Array.isArray(err.responseJSON.message)){ err.responseJSON.message.forEach(function(v) { error(v) }) } error(err.responseJSON.message) }) });