Foros del Web » Programando para Internet » Javascript » Frameworks JS »

me sale "undefined" NO PASA CON AJAX =/

Estas en el tema de me sale "undefined" NO PASA CON AJAX =/ en el foro de Frameworks JS en Foros del Web. ola amigos del foro tengo el siguiente problema =/ tengo una clase en PHP que le paso una ruta y me lista sus directorios y ...
  #1 (permalink)  
Antiguo 22/08/2008, 10:11
 
Fecha de Ingreso: febrero-2008
Mensajes: 16
Antigüedad: 16 años, 2 meses
Puntos: 0
me sale "undefined" NO PASA CON AJAX =/

ola amigos del foro tengo el siguiente problema =/

tengo una clase en PHP que le paso una ruta y me lista sus directorios y archivos

[CLASS DIRECTORIO]
directorio.php
-----------------

Código PHP:
<script type="text/javascript" src="ajax.js"></script>
<style type="text/css">
<!--
.style1 {font-family: Verdana;font-size: 10px;}
.style2 {font-family: Verdana;font-size: 12px;}

A.menu_t:link {    COLOR: #333333;FONT-FAMILY:  Verdana; FONT-SIZE: 10px; TEXT-DECORATION: none}
A.menu_t:visited { COLOR: #333333;FONT-FAMILY: Verdana; FONT-SIZE: 10px;  TEXT-DECORATION: none}
A.menu_t:active { COLOR: #333333;FONT-FAMILY:  Verdana; FONT-SIZE: 10px; TEXT-DECORATION: none}
A.menu_t:hover { COLOR: #333333;FONT-FAMILY:  Verdana; FONT-SIZE: 10px; TEXT-DECORATION: underline}
-->
</style>
<?php
    
function doHtmlUrl($url,$name)
{    
?>
    
    <a href="javascript: void(0);" onclick="buscarDirectorio('<?php echo $url?>')" class="menu_t"><?php echo $name;?></a><br> 
    

<?php }?>

<?
class directorio
{
    public 
$ruta;
    
    public function 
ListarDirectorio($dir)
    {

        if (
is_dir($dir)) 
        {
            if (
$gd opendir($dir)) 
            {
            echo 
"<span class='style2'>$dir</samp><br/><br/>";
                    
                    
// aqi mpieza el MENU
                    
echo "<ul>";
                    while ((
$archivo readdir($gd)) !== false
                    {        
                            echo 
"<li>";    
                            if (
is_dir($dir $archivo))
                            {    
                                
                echo 
"<img src='img/Carpeta.PNG' width='19' height='16' onclick='verInfo($dir, $archivo)'/>";    
        
//ListarDirectorio($dir . $archivo . "/");        
                                
doHtmlUrl($dir $archivo "/",$archivo);    
                                
//doHtmlUrl($dir, $archivo);    
                                
                                //ListarDirectorio($dir . $archivo . "/");
                            
}
                                                                                                        
                            if (
is_file($dir $archivo) && $archivo!="." && $archivo!="..")
                            {    
                                echo 
"<img src='img/archivo.PNG' width='18' height='22' /> ";    
                                echo 
"<span class='style1'><strong>".$archivo."</strong></span>";
                            }
                            echo 
"</li>";
                    }      
                    
// aqi termina el MENU
                    
echo "</ul>";
        
closedir($gd);
            }
        }
    }

}
?>
y llamo a la clase en este archivo

VIEW.PHP

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>    

</head>
<body>
<form  name="fr1" action="" id="fr1"onSubmit="return false">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="57%" align="left" valign="top">
    <?php
        
require_once('directorio2.php'); 
        
$verte_toda=new directorio();
        
$verte_toda->ListarDirectorio("C:/AppServ/www/");
    
?>    </td>
    <td width="43%">
    <div id="resultados"></div>
    </td>
  </tr>
</table>
</form>
</body>
</html>
aqui esta mi AJAX

/* ------------------------------------------------------------------------------------- */
function mAjax()
{
var xmlhttp=false;
try
{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){

try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch (E) { xmlhttp = false;}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined'){ xmlhttp = new XMLHttpRequest();}
return xmlhttp;
}
/* ------------------------------------------------------------------------------------- */

//POR POST
function buscarDirectorio(ruta){
var contenedor=document.getElementById('resultados');
var datos=ruta.value;

ajax=mAjax();
ajax.open("POST","view_dir.php",true);
ajax.onreadystatechange=function()
{

if(ajax.readyState==4)
{ contenedor.innerHTML = ajax.responseText; }
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("datos="+datos);

}

//POR GET
function buscarD(ruta){
var contenedor=document.getElementById('resultados');
var datos=ruta.value;
var ajax0 = mAjax();

ajax0.onreadystatechange=function(){

if(ajax0.readyState==4){
contenedor.innerHTML = ajax0.responseText;

}
}
ajax0.open("GET","view_dir.php?datos="+encodeURICo mponent(datos),true);
ajax0.send(null);
return false;
}

lo eh intentado por los 2 metodos y cuando lo hago por POST me bota "undefined"
pero si lo prubeo manualmente poniendo en la URL

http://localhost/Mi_Directorio_Enrutado_2/PHP/view_dir.php?datos=C:/AppServ/www/Mi_Directorio_Enrutado_2/

me resulta quiere decir que el AJAX no esta pasando el valor pero no se donde tengo el ERROR ayudaaa

esta es mi pagina a la que llamo con el AJAX

view_dir.php
Código PHP:
<?php
        $dir
=$_REQUEST['datos'];
        
//$dir="C:/AppServ/www/Mi_Directorio_Enrutado_2/";
        
require_once('directorio2.php'); 
        
$verte_toda=new directorio();
        
$verte_toda->ListarDirectorio($dir);        
        echo 
$dir;            
?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:03.