teacher.php
<?php
include('php/conexion.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$grupo = $_POST['grupo'];
$getNotas = mysqli_query($con,"SELECT * FROM notas WHERE grupo='$grupo'") or die ('error al obtener datos de grupos');
}
$login=1;
$getNotas="";
$getDocente = mysqli_query($con,"SELECT * FROM docentes WHERE ID='$login'") or die ('error al obtener datos de alumno');
$getGrupo = mysqli_query($con,"SELECT * FROM grupos WHERE docente='$login'") or die ('error al obtener datos de grupos');
?>
<!DOCTYPE html> .....
//Donde se muestra la lista de grupos.
<div class="container" id="evaluacion" style="display:none;">
<div class="tipo-apilados" style="width:300px; height:140px; border-radius:3px;">
<label class="aviso_usuario">Para iniciar la evaluación selecciona los siguientes datos:</label>
<label class="info_texto">Seleccion un grupo</label>
<select name="grupos" class="editText" id="grupo_evaluar">
<option selected value="0">Mis grupos</option>
<?php
$row=mysqli_fetch_array($getGrupo,MYSQLI_ASSOC);
echo "<option value='".$row['ID']."'>".$row['nombre']."</option>";
?>
</select>
<button id="d_evaluacion" type="button" name="button" class="botonGuardar">Iniciar evaluación</button>
</div>
<!--Tabla de notas de alumnos-->
<?php
if (!empty($grupo)){
//Creamos tabla
$row_cnt = mysqli_num_rows($getNotas);
echo "
<div class='tipo-apilados' style='width:700px; height:auto; border-radius:3px; display:none;' id='info_evaluacion'>
<label class='aviso_usuario'>Modificar calificación de los estudiantes</label>
<label style='padding:3px; border-radius:3px; color:#555; background-color:#EEE; font-size:13px;'>".$row_cnt." Alumnos registrados</label>
<input type='text' name='' value='' placeholder='Buscar alumno por nombre' class='editText'>
<table style='width:100%; margin-top:5px;'>
<tr>
<th style='width:150px;'>Alumno</th>
<th style='width:10px; font-size:12px; background-color:#FFF;'>Final</th>
<th style='width:20px; font-size:12px; background-color:#FFF;'>Unidad 1</th>
<th style='width:20px; font-size:12px; background-color:#FFF;'>Unidad 2</th>
<th style='width:20px; font-size:12px; background-color:#FFF;'>Unidad 3</th>
<th style='width:20px; font-size:12px; background-color:#FFF;'>Unidad 4</th>
<th style='width:20px; font-size:12px; background-color:#FFF;'>Opciones</th>
</tr>
";
while($row = mysqli_fetch_array($getNotas,MYSQLI_ASSOC))
{
echo "
<tr>
<td>".$row['alumno']."</td>
<td>".$row['promedio']."</td>
<td>".$row['unidad_1']."</td>
<td>".$row['unidad_2']."</td>
<td>".$row['unidad_3']."</td>
<td>".$row['unidad_4']."</td>
<td><button type='button' name='button' class='botonNormal' style='padding:2px; font-size:12px; width:90%;'>Editar</button></td>
</tr>
</table>
";
}
}
?>
Jquery al presionar el boton
$(document).ready(function(){
$("#d_evaluacion").click(function(){
$seleccion = $('#grupo_evaluar option:selected').html();
if ($seleccion == "Mis grupos") {
$("#mensaje_error").fadeIn();
$("#mensaje_error").html("Debe seleccionar un grupo a evaluar");
$("#mensaje_error").delay(1000).fadeOut();
} else {
$("#info_evaluacion").slideDown();
$.ajax({url:'/ingles/teacher.php',method:'post',data:{"grupo":"1"}});
}
});
});
No me muestra nada, es decir al parecer al enviar la informacion por ajax, se puede ver que mando un "1" es el codigo de un grupo, el teacher.php no resive nada.
select
? En la petición Ajax no estás manejando la respuesta del servidor... debes usardone
para una respuesta exitosa, ofail
para una respuesta fallida.d_evaluacion
... y prueba la petición Ajax de esta manera:$.ajax({url:'index.php',method:'post',data:{"grupo":"1"}}).done(function(respuesta) { alert(respuesta);}).fail(function( jqXHR, textStatus ) {alert( "error" + textStatus); });