<script src="http://yui.yahooapis.com/3.12.0/build/yui/yui-min.js"></script><scriptsrc="js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript">
function run(){
var id = $("#id_Turma").val();
console.log(id);
$.ajax({
url : "includes/disciplina.php/",
type : "POST",
data : {
id : id
},
success : function(JSON) {
$("#idDiciplina").html("");
console.log(JSON);
$('#idDiciplina').append("<option value='' selected='selected'>Disciplinas</option>");
for (var i = 0; i < JSON.length; i++) {
$('#idDiciplina').append("<option value="+JSON[i][0]+">" + JSON[i][1] + "</option>");
}
}
});
}
Look at the code I can not seem to identify because I can not get the json values by the way.
<?php
//include('../seguranca.php');
$id_turmar = $_POST['id'];
$consulta = DB::getConn()->prepare("SELECT idDisciplina, Nome FROM 'disciplina' WHERE Turma_idTurma = :Turma_idTurma;");
$consulta->bindParam(':Turma_idTurma', $id_turmar, PDO::PARAM_STR);
$consulta->execute();
while ($assunto = $consulta->fetch(PDO::FETCH_ASSOC)) {
$assunto_post[] = array(
'idDisciplina' => $assunto['idDisciplina'],
'Nome' => utf8_encode($assunto['Nome']),
);
}
echo(json_encode($assunto_post));