jQuery get() no devuelve respuesta
Publicado por Diego (13 intervenciones) el 14/12/2015 08:13:52
Hola amig@s!
Tengo este problema y espero que puedan ayudarme, ya que lo he intentado y no funciona
Tengo este código jQuery que me envia datos a un archivo PHP y devuelve valores de la DB
Este es el PHP
Este es el select en el que se escriben los datos recibidos
Gracias.
Saludos!!
Tengo este problema y espero que puedan ayudarme, ya que lo he intentado y no funciona

Tengo este código jQuery que me envia datos a un archivo PHP y devuelve valores de la DB
1
2
3
4
5
6
7
8
9
$(document).ready(function(){
$("#searchStudents").click(function(){
idGrade = $("#gid").find(':selected').val();
idGroup = $("#grid").find(':selected').val();
$.post("../includes/getStudents.php", { idGrade: idGrade, idGroup: idGroup }, function(data){
$("#stid").html(data);
});
});
});
Este es el PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
$hostname_sec0906 = "localhost";
$database_sec0906 = "system_sec";
$username_sec0906 = "root";
$password_sec0906 = "******";
$sec0906 = mysql_pconnect($hostname_sec0906, $username_sec0906, $password_sec0906) or trigger_error(mysql_error(),E_USER_ERROR);
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$idGrade = $_POST['idGrade'];
$idGroup = $_POST['idGroup'];
mysql_select_db($database_sec0906, $sec0906);
$query_students = "SELECT * FROM students WHERE students.id_grade = ".$idGrade." AND students.id_group = ".$idGroup." ORDER BY students.surnames";
$students = mysql_query($query_students, $sec0906) or die(mysql_error());
$row_students = mysql_fetch_assoc($students);
$totalRows_students = mysql_num_rows($students);
if($totalRows_students > 0){
do{
$respuesta.= '<option value="'.$row_students['id_student'].'">'.htmlentities($row_students['surnames'], ENT_COMPAT, 'utf-8')." ".htmlentities($row_students['name'], ENT_COMPAT, 'utf-8').'"</option>"';
}while($row_students = mysql_fetch_assoc($students));
echo $respuesta;
}else{
echo('<script type="text/javascript">alert("Error de Sistema")</script>');
}
mysql_free_result($students);
?>
Este es el select en el que se escriben los datos recibidos
1
<select name="stid" id="stid"></select>
Gracias.
Saludos!!
Valora esta pregunta


0