$(function() { $('select[autocomplete="off"]').each(function() { let selectedValue = $(this).find('option[selected]').val(); if (selectedValue) { $(this).val(selectedValue); } }); }); function vorantragAbschicken(){ let data = {}; data.event = $('#eventSelect').val(); data.passport_type = $('#passport_type').val(); data.mail = $('#mail').val(); data.first_name = $('#firstname').val(); data.last_name = $('#lastname').val(); data.location = $('#location').val(); console.log(data); $.ajax({ type: "POST", url: "/vorbeantragen/absenden", data: data, dataType: "json", success:function(r){ if(r.messageStatus === "success"){ $('#mail').val(""); $('#firstname').val(""); $('#lastname').val(""); $('#location').val(""); alert(r.errorMessage); } else { alert(r.errorMessage); } }, error:function(r, a, e){ alert(e); } }); }