Comunidad de diseño web y desarrollo en internet online

Problema Ajax Firefox

Citar            
MensajeEscrito el 07 Oct 2008 04:42 am
Pero no funciona ajax en Firefox 3.0.3, si funciona en IE7. Quiero probar con un simple "hola mundo" que aparezca al presionar un boton. He buscado harto y no encuentro código que funcione. Gracias de antemano.

El codigo de cada pagina es:

PAGINA UNO:

<!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" xml:lang="es" lang="es">
<head>
<title>Mi pagina</title>

<script type="text/javascript">
function nuevoAjax(){
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;
}

function enviar(){
ajax=new nuevoAjax();
ajax.open("GET", "borrar2.php",true);

cuerpo.innerHTML = "Un momento...";
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
cuerpo.innerHTML = ajax.responseText
}
}
ajax.send(null)


}

</script>
</head>
<body>
<div id="cuerpo">
<input type="submit" name="Submit" value="Enviar" onclick="enviar();" />
</div>

</body>
</html>


PAGINA borrar2.php

<?php echo "hola mundo";
?>

Por kileno

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Oct 2008 04:46 am
Ya lo solucioné, por si a alguien le sirve, borre la linea:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Con eso queda ok.

Por kileno

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 09 Oct 2008 03:12 pm

kileno escribió:

Ya lo solucioné, por si a alguien le sirve, borre la linea:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Con eso queda ok.


Encontré ua solución más óptima, es mejor poner esto:

<!--[if lte IE 6]>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<![endif]-->
<!--[if lte IE 7]>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<![endif]-->


Se me ocurrio poner eso porque se pueden originar problemas si no se pone al trabajar con XHTML transitional, con esto se solucion al 100%

Por kileno

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 23 Feb 2010 07:47 pm
hola a todos.

tengo un problema con una rutina en ajax, me funciona en ie pero cuando lo ejecuto en firefox no me funciona, haber si me pueden ayudar, gracias de antemano.

Primero en mi pag web:

<%
vSQL = "SELECT DISTINCT C.PAI_PK, C.PAI_DESC FROM SL_EMPRESA A, SL_EMP_PER B, " +
"SL_PAIS C WHERE B.PER_PK=" + session.getAttribute("g_PER_PK") + " AND " +
"A.EMP_FLAG2='A' AND B.EP_FLAG='A' AND C.PAI_FLAG='A' AND " +
"A.EMP_PK=B.EMP_PK AND A.PAI_PK=C.PAI_PK ";
out.println(Rutinas.LlenaCombo(vSQL,"cboxPAI_PK",
"f_limpiar_empresa();ajaxInterface(\'param=\'+this.value,AJAX_PAG_WEB1.value,AJAX_CONTENEDOR1.value)"));
%>

donde Rutinas.LlenaCombo se encarga de cargar un combo (<select>) que se llama cboxPAI_PK, como tercer parametro paso f_limpiar_empresa(); que se encarga de limpiar el combo en el evento onchange y onclick luego llamo a la función ajaxInterface que pasa 3 parametros, el primero es el valor del parametro, el segundo la pagina web que utiliza el ajax y el tercer valor el contenedor donde se mostrara el resultado cada vez que cambie (change) o haga clic (en el combo)... El resultado es otro combo, que se arma en AJAX_PAG_WEB1.value.

Luego mi interface con ajax es como sigue:

<script type="text/javascript">
var xmlhttp, contenedor
function ajaxInterface(param, pagweb, contiene)
{
contenedor=contiene;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Tu navegador no soporta AJAX.");
return;
}
var url=pagweb;
url=url+"?"+param;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById(contenedor).innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
//Aca entra en IE8
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
//return new ActiveXObject("Microsoft.XMLHTTP");
try {
return new ActiveXObject("MSXML2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Tu navegador no soporta AJAX.");
}
}
}
return null;
}
</script>

Me funciona excelente en IE pero no en firefox, he probado de todo pero no me funciona. Agradecere la ayuda.

Inclusive probe poner un alert justo ante de contenedor=contiene; pero ni siquiera llega a este punto. El Firefox no hace nada, no me sale error ni nada de nada... solo sale el combo vacio. Pero el mismo codigo lo ejecuto en IE8 y sale todo bien.

Por mmaximiliano

0 de clabLevel



 

msie8
Citar            
MensajeEscrito el 15 May 2010 04:55 pm
Hola mmaximiliano soy nuevo aqui.. voy a tratar de ayudar:

tu dices que no sale el alert aun cuando lo pones antes de contenedor=contiene; entonces esto quiere decir que no esta entrando a la funcion primero prueba poniendo las variables separadas asi:
var xmlhttp;
var contenedor;
si el error persiste prueba poniendo en la etiqueta javascript en ves de type pon language asi <script language="javascript">
si el error continua, no sabria que decirte. Lo que si te puedo decir es que solo en IExplorer acepta el paso del nombre de los div como variables osea cuando pones
"document.getElementById(contenedor).innerHTML=xmlhttp.responseText;" en IE si va a funcionar pero en el resto de navegadores no, la razon no la se la estoy tratando de encontrar solo se que sí funciona cuando pones el nombre del div de frente entre comillas simples asi:
document.getElementById('div_uno').innerHTML=xmlhttp.responseText;

SI ALGUIEN ME PUDIERA AYUDAR CON EL TEMA DEL DIV, COMO PASARLO COMO VARIABLE EN JScript PARA QUE EL AJAX FUNCIONE BIEN PARA FIREFOX SE LO AGRADECERIA!!

Por gastonchiquillo

0 de clabLevel



 

msie8

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.