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

PROBLEMA AJAX OCN IE6 ¿solucion?

Estas en el tema de PROBLEMA AJAX OCN IE6 ¿solucion? en el foro de Frameworks JS en Foros del Web. buenas, estoy desarrollando una plicacion web con ajax, jsp y servlet, pero uno de mis codigos ajax no funciona, a este codigo lo ejecuto desde ...
  #1 (permalink)  
Antiguo 17/09/2009, 22:11
 
Fecha de Ingreso: febrero-2008
Mensajes: 54
Antigüedad: 16 años, 2 meses
Puntos: 0
Pregunta PROBLEMA AJAX OCN IE6 ¿solucion?

buenas, estoy desarrollando una plicacion web con ajax, jsp y servlet, pero uno de mis codigos ajax no funciona, a este codigo lo ejecuto desde un boton html pero, jee funciona con el firefox pero no funka con el IE 6, alguien sabe una solucion???

aca mi codigo ajax:

Código ajax:
Ver original
  1. function Enviar() {
  2.  
  3.                 var obj = false;
  4.  
  5.                 if (window.XMLHttpRequest) {
  6.                     //Cuidado aqui, el objeto XMLHttpRequest no esta disponible en versiones previas a IE7
  7.                     obj = new XMLHttpRequest();
  8.                 } else {
  9.                     return false;
  10.                 }
  11.                 obj.onreadystatechange = function () {
  12.                     if ( obj.readyState == 4 && (obj.status == 200 || window.location.href.indexOf ("http")==- 1)) {
  13.                         document.getElementById("Respuesta_Libro").innerHTML = obj.responseText;
  14.                     } else {
  15.                         "procesando..."
  16.                     }
  17.                 };
  18.                 obj.open("GET", "ServletLibro?codigo=" + document.getElementById("codigo").value +"&lector="+ document.getElementById("lector").value +"&libro="+ document.getElementById("libro").value +"&tipo="+ document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value + "&fecha=" + document.getElementById("dateArrival").value, true);
  19.                 obj.send(null);
  20.  
  21.                 return (true);
  22.             }

aca mi codigo html:

Código html:
Ver original
  1. <&#37;[arroba]page contentType="text/html" pageEncoding="iso-8859-1"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  3.   "http: // www . w3 . org/TR/html4/loose.dtd">
  4.  
  5.     <head>
  6. <!-- ACA PONGO EL CODIGO AJAX DE ARRIBA -->    
  7.  
  8.         <!--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">-->
  9.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  10.         <title>MOVIMEINTO DE LIBROS</title>
  11.         <script language='javascript' src="popcalendar.js"></script>
  12.         <link href="estilo.css" rel="stylesheet" type="text/css">
  13.     </head>
  14.     <body>
  15.         <div id="contenedor">
  16.             <div class="background">       
  17.                     <center>
  18.                         <marquee>
  19.                             <p class="titulos">AJAX Y JSP + SERVLETS</p>
  20.                         </marquee>
  21.                     </center>      
  22.             </div>
  23.  
  24.             <div id="contenido"><br />
  25.                 <br>
  26.                 <p>&nbsp;</p>
  27.                 <div id="centra">
  28.                 <form name="form1" action="ServletLibro" method="post">
  29.                     Codigo Libro:<input type="text" name="codigo" value="" id="codigo" />
  30.                     <br><br>
  31.                     Nombre del Lector:<input type="text" name="lector" value="" id="lector" />
  32.                     <br><br>
  33.                     Libro:<input type="text" name="libro" value="" id="libro" />
  34.                     <br><br>
  35.                     Tipo Movimiento:<select name="tipo" id="tipo">
  36.                         <option id="mov">Reserva</option>
  37.                         <option id="mov">Prestamo</option>
  38.                         <option id="mov">Devolucion</option>
  39.                     </select>
  40.                     <br><br>
  41.                     Fecha Movimiento:<input name="nombre_de_la_caja" type="text" id="dateArrival" onClick="popUpCalendar(this, form1.dateArrival, 'mm-dd-yyyy');" size="10">
  42.                     <br><br><br>
  43.                     <input type="button" value="Enviar" onclick="Enviar();" name="enviarAjax">
  44.                 </form>
  45.  
  46.                 <div id="Respuesta_Libro" tex-align="center" style=" position:absolute; top:auto; left:auto; tex-align:center;">
  47.  
  48.                     <!-- Este DIV contendra la respuesta enviada por el Servlet -->
  49.  
  50.                 </div>
  51.  
  52.             </div>            
  53.         </div>
  54.     </body>
  55. </html>

BUEMNO ESPERO A UN MAESTRO BIEN CAPO ME PUEDA AYUDAR...creo q hay muchos cno este problema...


------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------S O L U C I O N---------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------

bueno pal que tenga este problema, aui le pongo la gran y solucion pa q no se maten buscando:

Código script:
Ver original
  1. <script language="javascript" type="text/javascript">
  2.            /* function getHttpRequest()
  3.             {
  4.                 var httpReq;
  5.                 //Si es Mozilla, Opera, etc...
  6.                 if (window.XMLHttpRequest)
  7.                 {
  8.                     httpReq = new XMLHttpRequest();
  9.                 }
  10.                 else //Internet Explorer lo expone como control Active X
  11.                 {
  12.                     httpReq = new ActiveXObject("Microsoft.XMLHTTP");
  13.                 }
  14.             }*/
  15.  
  16.  
  17.  
  18.             function Enviar() {
  19.  
  20.                 //var obj = false;
  21.  
  22.                 /*if (window.XMLHttpRequest) {
  23.                     //Cuidado aqui, el objeto XMLHttpRequest no esta disponible en versiones previas a IE7
  24.                     obj = new XMLHttpRequest();
  25.                 } else {
  26.                     return false;
  27.                 }*/
  28.  
  29.                 var httpReq;
  30.                 //Si es Mozilla, Opera, etc...
  31.                 if (window.XMLHttpRequest)
  32.                 {
  33.                     httpReq = new XMLHttpRequest();
  34.                 }
  35.                 else //Internet Explorer lo expone como control Active X
  36.                 {
  37.                     httpReq = new ActiveXObject("Microsoft.XMLHTTP");
  38.                 }
  39.  
  40.                 //http = getHttpRequest()
  41.                 http = httpReq;
  42.  
  43.                 http.onreadystatechange = function () {
  44.                     if ( http.readyState == 4 && (http.status == 200 || window.location.href.indexOf ("http")==- 1)) {
  45.                         document.getElementById("Respuesta_Libro").innerHTML = http.responseText;
  46.                     } else {
  47.                         "procesando..."
  48.                     }
  49.                 };
  50.  
  51.                 http.open("GET", "ServletLibro?codigo=" + document.getElementById("codigo").value +"&lector="+ document.getElementById("lector").value +"&libro="+ document.getElementById("libro").value +"&tipo="+ document.getElementById("tipo").options[document.getElementById("tipo").selectedIndex].value + "&fecha=" + document.getElementById("dateArrival").value, true);
  52.                 http.send(null);
  53.  
  54.                 return (true);
  55.             }
  56.         </script>

Última edición por JoNhNaTaN; 18/09/2009 a las 01:22 Razón: SOLUCIONADO
  #2 (permalink)  
Antiguo 17/09/2009, 22:23
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: PROBLEMA AJAX OCN IE6 ¿solucion?

Tu problema es que IE6 no soporta el objeto XMLHttpRequest, necesitas instanciar uno usando el objeto ActiveX de MS. Busca en el foro hay muchos ejemplos de como iniciar un objeto AJAX que sea cross-browser.

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 21:01.