I have this select, values are in coming from a database
<select id="construido" name="construido" class="form-select form-select-sm" aria-label=".form-select-sm example">
<option id="construido-0" selected class="form-control"></option>
<option id="construido-1" value="1"> </option>
<option id="construido-2" value="2"> </option>
</select>
But now I am trying to get the selected text to send it to another table using ajax php. I tried this but i can access construidoSelected only inside the function
$(document).on('change', '#construido', function () {
let construidoSelected = $("#construido option:selected").text()
});
let start = 0, url = "http://localhost:8077/connectpost/validations/sendinterview.php";
$(document).ready(function () {
$('#form_interview').submit(function (e) {
$.post(url, {
fuente:"",
construido:"",
recibir: $("#recibir-agua").val(),
horas: $("#horas-agua").val(),
});
$("#recibir").val("");
$("#horas").val("");
return false;
})
});