Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/12/2010, 21:13
jrod_master
 
Fecha de Ingreso: diciembre-2010
Mensajes: 12
Antigüedad: 13 años, 8 meses
Puntos: 0
Exclamación problema con open ajax

hola chicos soy nuevo aqui...
tengo un problema y no le encuentro la solucion por ninguna parte
lo que sucede es que instancie el metodo el objeto httprequest a una variable
ejemplo var probando = getXMLHTTPRequest();
y me da un error en la consola de errores, me dice que probando no es una funcion
ahi les va el codigo a ver que me dicen
grasias espero que me puedan ayudar...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>primer ejemplo ajax</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
</head>
<body bgcolor="#FFFFFF">
<script type="text/javascript">
function getXMLHTTPRequest(){
try {
req = new XMLHTTPRequest();
} catch(err1){
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
}catch (err2){
try{
req = ActiveXObject("Microsoft.XMLHTTP");
}catch (err3){
req = false;
}
}
}
return req;
}

var probando = getXMLHTTPRequest();

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

function respuestaajax(){
if(probando.readyState == 4){
if(probando.status == 200){
alert("el server dijo " + probando.responseText);
}else {
alert('ha ocurrido un error '+ probando.statusText);
}

}
}
</script>
<form name = 'form1'>
Nombre:<input type="text" name = 'minombre' onblur ='llamarajax()';><br>
Telefono:<input type="text" name = 'telefono'><br>
<input type="submit" value= "enviar">
</body>

</html>