Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/07/2010, 04:05
stromper
 
Fecha de Ingreso: marzo-2010
Mensajes: 11
Antigüedad: 14 años, 2 meses
Puntos: 0
Problema simple con AJAX

Hola miren mi script no funciona y es el siguiente
Código Javascript:
Ver original
  1. // AJAX Connection //
  2. function ajax() {
  3. try {
  4. req = new XMLHttpRequest();
  5. } catch(err1) {
  6.   try {
  7.   req = new ActiveXObject("Msxml2.XMLHTTP");
  8.   } catch (err2) {
  9.     try {
  10.     req = new ActiveXObject("Microsoft.XMLHTTP");
  11.     } catch (err3) {
  12.       req = false;
  13.     }
  14.   }
  15. }
  16. return req;
  17. }
  18. var ajax = ajax();
  19.  
  20. function llamar(){
  21. var url = "america.php";
  22. var miAleatorio = parseInt(Math.random()*99999999);
  23. ajax.open("GET", url + "&rand=" + miAleatorio);
  24. ajax.onreadystatechange = respuesta();
  25. ajax.send(null);
  26. }
  27. function respuesta() {
  28.     if(ajax.readyState == 4) {
  29.         if(ajax.status == 200) {
  30.             window.alert(ajax.responseText);
  31.         }
  32.     }else{
  33.         document.getElementById('eltiodiv').innerHTML = "<img src='ajax icons (18).gif' />" ;
  34.         }
  35. }
el archivo america.php solo imprime hola nada mas no es nada complicado pero ahora el tema es por que no me funciona que hize mal???