jquery con getJSON problema
Publicado por alex (1 intervención) el 08/10/2011 01:58:19
Buen dia a todos, soy nuevo utilizando jquery y deseo implementar el método getJSON tengo algunos ejemplos que no puedo hacer que corran, no se identificar el error dado que nunca lo e utilizado les dejo la URL del código, para que vean que tiene mal o que necesito agregar. Les agradezco mucho su ayuda.
http://www.javascriptya.com.ar/jquery/temarios/descripcion.php?cod=83&punto=28&inicio=18
pagina1.html
funciones.js
pagina1.php
http://www.javascriptya.com.ar/jquery/temarios/descripcion.php?cod=83&punto=28&inicio=18
pagina1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html>
<head>
<title>Problema</title>
<link rel="StyleSheet" href="estilos.css" type="text/css">
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="funciones.js"></script>
</head>
<body>
Ingrese dni (solo existen los valores 1,2 y 3):<input type="text"
name="dni" id="dni" size="10"><br>
<input type="button" value="Enviar" id="boton1">
<div id="resultados"></div>
</body>
</html>
funciones.js
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
var x;
x=$(document);
x.ready(inicializarEventos);
function inicializarEventos()
{
var x;
x=$("#boton1");
x.click(presionSubmit);
}
function presionSubmit()
{
var v=$("#dni").attr("value");
$.getJSON("pagina1.php",{dni:v},llegadaDatos);
return false;
}
function llegadaDatos(datos)
{
$("#resultados").html("Nombre:"+datos.nombre+
"<br>"+"Apellido:"+
datos.apellido+"<br>"+
"Direccion:"+datos.direccion);
}
pagina1.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
<?php
header('Content-Type: text/txt; charset=ISO-8859-1');
$nombre='';
$apellido='';
$direccion='';
if ($_REQUEST['dni']=='1')
{
$nombre='Juan';
$apellido='Rodriguez';
$direccion='Colon 123';
}
if ($_REQUEST['dni']=='2')
{
$nombre='Ana';
$apellido='Maldonado';
$direccion='Lima 245';
}
if ($_REQUEST['dni']=='3')
{
$nombre='laura';
$apellido='Pueyrredon';
$direccion='Laprida 785';
}
echo "{
'nombre':'$nombre',
'apellido':'$apellido',
'direccion':'$direccion'
}";
?>
Valora esta pregunta


0