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

AJAX + Internet Explorer + PHP

Estas en el tema de AJAX + Internet Explorer + PHP en el foro de Frameworks JS en Foros del Web. Hola a todos, tengo un codigo en Ajax que me llena un <select> segun otro, el caso es que con firefox me funciona de maravilla, ...
  #1 (permalink)  
Antiguo 18/12/2008, 07:28
 
Fecha de Ingreso: noviembre-2008
Mensajes: 101
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta AJAX + Internet Explorer + PHP

Hola a todos, tengo un codigo en Ajax que me llena un <select> segun otro, el caso es que con firefox me funciona de maravilla, pero con IExplorer me da error, no se porque, aqui les muestro mi código, para que me ayuden...
codigo en ajax
Código:
<script>

/***********************************************************************************/
function Enviar_MostrarEnCapa(url,capa,funcion,valores)
{
	var ajax=creaAjax();
	if(capa != null && capa!= '')
	var capaContenedora = document.getElementById(capa);
	ajax.open ('POST', url, true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState==1)
		{
			if(capa != null && capa!= '')
			capaContenedora.innerHTML="Cargando...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				if(capa != null && capa!= '')
				capaContenedora.innerHTML=ajax.responseText;
				if(funcion != null && funcion!= '')
				eval(funcion);
			}
			else if(ajax.status==404)
			{
				if(capa != null && capa!= '')
				capaContenedora.innerHTML = "La direccion no existe";
			}
			else
			{
				if(capa != null && capa!= '')
				capaContenedora.innerHTML = "Error: ".ajax.status;
			}
		}
	}
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(valores);
	return;
}
/***********************************************************************************/
function creaAjax()
{
	var objetoAjax=false;
	try {
		/*Para navegadores distintos a internet explorer*/
		objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try {
			/*Para explorer*/
			objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		}

		catch (E)
		{
			objetoAjax = false;
		}
	}

	if (!objetoAjax && typeof XMLHttpRequest!='undefined')
	{
		objetoAjax = new XMLHttpRequest();
	}
	return objetoAjax;
}
</script>
codigo en html
Código:
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?
require('ajax.php');
?>
<script>
<!--

function buscar_options0()
{
	Enviar_MostrarEnCapa('buscaroptions1.php','div_opciones1','','options0='+document.getElementById('options0').value ); 
        
}
//-->
</script>

</head>

<body bgcolor="#5F8FC5">
<div width="1024">
<?
include("Llenar.php");
$fp=file("tablas.def");
?>
<form action="prueba.php"  method="POST" name="formul" >
    
    <table width="957" border="0" align="center">
        <tr> 
        <td width="33">&nbsp;</td>
        <td width="33">&nbsp;</td>
        <td width="112">&nbsp;</td>
        <td width="298"><select name="options0" id="options0" onchange="buscar_options0();">
              <?
              Llenar_campos($fp);
			  ?>
            </select> 
       
        <td width="63"><div id="div_opciones1">
          <select name="opciones1" id="opciones1">
          </select>
          </div></td></tr>
          </table>
</form>
</div>
</body>
</html>
Por favor cualquier tipo de ayuda para mi problema será muy agradecida, es que no se que mas voy a hacer
  #2 (permalink)  
Antiguo 18/12/2008, 10:07
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AJAX + Internet Explorer + PHP

¿Que error te da?

Saludos.
  #3 (permalink)  
Antiguo 18/12/2008, 11:00
Avatar de MaBoRaK  
Fecha de Ingreso: abril-2003
Ubicación: La Paz - Bolivia
Mensajes: 2.003
Antigüedad: 21 años
Puntos: 35
Respuesta: AJAX + Internet Explorer + PHP

loading..........

que es esto?

if(capa != null && capa!= '')
capaContenedora.innerHTML=ajax.responseText;
if(funcion != null && funcion!= '')
eval(funcion);


Acostumbrate a usar llaves o bien ponerle un TAB o ESPACIO al cuerpo del IF

if(capa != null && capa!= '')
{
capaContenedora.innerHTML=ajax.responseText;
}
if(funcion != null && funcion!= '')
{
eval(funcion);
}
.

supongo que es así. Tambien puede ser que tu variable funcion tenga código erroneo.


connection closed.
__________________

Maborak Technologies
  #4 (permalink)  
Antiguo 18/12/2008, 11:12
 
Fecha de Ingreso: noviembre-2008
Mensajes: 101
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta Respuesta: AJAX + Internet Explorer + PHP

El erro que me da es el sgte:

Código:
Warning: stristr() [function.stristr]: Empty delimiter. in D:\xampp\htdocs\Interroga\Tablas.php on line 10

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause., SQL state 37000 in SQLExecDirect in D:\xampp\htdocs\Interroga\obtenerunicos.php on line 17

Warning: odbc_fetch_array(): supplied argument is not a valid ODBC result resource in D:\xampp\htdocs\Interroga\obtenerunicos.php on line 20
Y no se porque porque en firefox me funciona a las mil maravillas...
  #5 (permalink)  
Antiguo 18/12/2008, 11:20
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AJAX + Internet Explorer + PHP

Esos son errores en PHP creo.., al parecer no le estas enviando algun dato a tu script desde AJAX.

Saludos.
  #6 (permalink)  
Antiguo 18/12/2008, 14:14
 
Fecha de Ingreso: noviembre-2008
Mensajes: 101
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta Respuesta: AJAX + Internet Explorer + PHP

Puede ser que sea un error en mi código PHP, pero no lo creo, porque en firefox no me da ningun tipo de error haciendo lo mismo que hago con IEexplorer, por eso supuse que seria algo con ajax e IExplorer, alguna sujerencia??
  #7 (permalink)  
Antiguo 18/12/2008, 14:40
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AJAX + Internet Explorer + PHP

Por eso, como te comente, prueba hacer un alert(valores) antes de ajax.send(valores) para que veas los valores que le estas enviando al script.

Saludos.
  #8 (permalink)  
Antiguo 15/01/2009, 10:17
 
Fecha de Ingreso: noviembre-2008
Mensajes: 101
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta Respuesta: AJAX + Internet Explorer + PHP

Bunas amigos, retomanto este topic, pues no he solucionado nada de nada, no entiendo que está pasando, con firefox todo funciona a la perfeccion, pero cuando trato de hacer lo mismo con IExplorer, el mismo error, y no se poruqe, por cierto GastorV, hice lo que me recomendaste, en firefox el alert dice : "oprtions0 = Código" y en IExplorer dice: "options0 = "
Que puede ser esto, ayudenme amigos, por favor
  #9 (permalink)  
Antiguo 15/01/2009, 11:13
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AJAX + Internet Explorer + PHP

Mmm en ese caso ya diste con el error, en IExplorer no estas rescatando el valor, si es un elemento del tipo select trata de rescatar el valor con el index correcto:

Código javascript:
Ver original
  1. var select = document.getElementById('el_Select');
  2. var valor = select.options[select.selectedIndex].value;

Saludos
  #10 (permalink)  
Antiguo 15/01/2009, 14:12
 
Fecha de Ingreso: noviembre-2008
Mensajes: 101
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta Respuesta: AJAX + Internet Explorer + PHP

Pues no GastorV, no me ha funcionado, no se que puedo hacer
  #11 (permalink)  
Antiguo 15/01/2009, 14:21
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AJAX + Internet Explorer + PHP

Como te comento tu problema es al rescatar los valores, aprende como hacerlo desde IE y luego agregale la parte de AJAX.

Por otro lado te pido escribas mi nombre correctamente.

Saludos
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 19:52.