Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2010, 01:29
Avatar de rodrigo791
rodrigo791
 
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 5 meses
Puntos: 168
No puedo crear el objeto xmlhttprequest

hola, tengo un script que me tiene q crear un Objeto XMLHTTPRequest pero no lo crea, en todos los navagadores lo prove, es igual para todos
ACA ESTA EL CODIGO:

Código HTML:
<!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>Enviar una petición al servidor</title>
</head>

<body>
<script language="javascript">
function getXMLHTTPRequest()
{
var req = false;
try
  {
    req = new XMLHttpRequest(); /* p.e. Firefox */
  }
catch(err1)
  {
  try
    {
     req = new ActiveXObject("Msxml2.XMLHTTP");
  /* algunas versiones IE */
    }
  catch(err2)
    {
    try
      {
       req = new ActiveXObject("Microsoft.XMLHTTP");
  /* algunas versiones IE */
      }
      catch(err3)
        {
         req = false;
        }
    }
  }
return req;
}

var miPeticion = getXMLHTTPRequest();

function llamarAjax() {
var apellido = document.form1.minombre.value;
var miAleatorio=parseInt(Math.random()*99999999);
var url = "miscriptdeservidor.php?apellido=" + apellido;
miPeticion.open("GET", url+ "&rand=" + miAleatorio, true);
miPeticion.onreadystatechange = respuestaAjax;
miPeticion.send(null);
}

function respuestaAjax() {
if(miPeticion.readyState == 4) {
if(miPeticion.status == 200) {
 ... declaraciones a ejecutar por el programa ...
        } else {
		alert("Ha ocurrido un error: " + miPeticion.statusText);
        }
    }
}
</script>

<form name='form1'>
Nombre: <input type='text' name='minombre' onblur='llamarAjax()' ><br>
Tel: <input type='text' name='teln'><br>
<input type='submit' value="enviar">
</form>
</body>
</html>