I am showing in a select the courses in which the student is not enrolled, this is to enroll the student in another course.
This select I fill in through a query, the problem is that when I click on add course to show me the form with the select that contains the courses in which that student is not enrolled, the data in the select at the moment of loading the page it appears and disappears in a matter of 1 second. It does not give any errors in console or anything. I've gone around and around but I can not figure out why.
I'll leave the PHP and JS code:
Here is my query to see the courses not enrolled by the student
function form_agg_curso_student(){
$id=$_GET['id_students'];
$query = "SELECT id,curso FROM cursos_abiertos WHERE cursos_abiertos.id
NOT IN ( SELECT inscritos.id_curso FROM inscritos WHERE
inscritos.id_student = '$id')";
$sql = $mysqli->query($query);
<select name="cursos" id="cursos" class="selectpicker form-control">';
while($row = $sql->fetch_assoc()){
$form.='<option value="'.$row['id'].'">'.$row['curso'].'</option>';
}
$form.='</select>
</div>
</form></div></div></div></div>';
return $form;
}
And this is my request with AJAX
$(document).ready(function(){
$('#cursos').on('change',function(){
var id = $("#cursos").val()
$.ajax({
type: 'POST',
url:'ver_monto.php',
data:{'id':id}
})
.done(function(listas_cursos){
$("#fecha").val(listas_cursos)
})
.fail(function(){
alert('error')
})
})
});
As I have already told you, the data appears and disappears in a matter of 1 second in the select, to which I can help with this problem, thank you very much. See:
That is the selection that should list the courses, but the data appears and disappears in a matter of a second