Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/08/2012, 17:05
Avatar de ONahuelO
ONahuelO
 
Fecha de Ingreso: junio-2009
Ubicación: Gualeguaychú, Argentina
Mensajes: 144
Antigüedad: 15 años, 10 meses
Puntos: 4
Error en funcion

Hola, les cuento estoy teniendo un error en una funcion y no se a que se deve:

Código Javascript:
Ver original
  1. var page = new Object;
  2.  
  3.  
  4. $.getJSON('http://127.0.0.1/api/main.php?ACT=dg', function(data)
  5. {
  6.     page = (data['page']);
  7.     alert(page['title']);
  8.    
  9. });

Haciendo esto me funciona bien, y me da un alert con el titulo, pero si hago esto:

Código Javascript:
Ver original
  1. var page = new Object;
  2.  
  3.  
  4. $.getJSON('http://127.0.0.1/api/main.php?ACT=dg', function(data)
  5. {
  6.     page = (data['page']);
  7.    
  8.    
  9. });
  10. alert(page['title']);

me devuelve un alert con undefined, como si no estubiera definida la variable.