Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/02/2010, 02:18
cslbcn
 
Fecha de Ingreso: marzo-2008
Mensajes: 383
Antigüedad: 16 años
Puntos: 5
Respuesta: simular pausa

Hola David. Hice lo que me dijiste y hace lo que quiero, por cada pasada del bucle hace la lectura Ajax, pero tengo un problema, en http.status me asigna 500 (error):

Código Javascript:
Ver original
  1. var numTarea;
  2. var enProceso = false; // lo usamos para ver si hay un proceso activo
  3. var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest
  4.  
  5. function getHTTPObject() {
  6.     var xmlhttp;
  7.     /*@cc_on
  8.     @if (@_jscript_version >= 5)
  9.     try {
  10.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  11.     } catch (e) {
  12.         try {
  13.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  14.         } catch (E) { xmlhttp = false; }
  15.     }
  16.     @else
  17.     xmlhttp = false;
  18.     @end
  19.     @*/
  20.     if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  21.         try {
  22.             xmlhttp = new XMLHttpRequest();
  23.         } catch (e) { xmlhttp = false; }
  24.     }
  25.     return xmlhttp;
  26. }
  27.  
  28. function verificaUsuario(dd) {
  29.    
  30.     if (!enProceso && http) {
  31.         var url = "ajax.aspx?fecha=" + dd + "/" + (mes + 1) + "/" + ano;        
  32.         http.open("GET", url, false);
  33.         http.onreadystatechange = handleHttpResponse;
  34.         http.send(null);  
  35.     }
  36. }
  37.  
  38. function handleHttpResponse() {
  39.     if (http.readyState == 4) {
  40.         alert(http.status);
  41.         if (http.status == 200) {
  42.            
  43.             if (http.responseText.indexOf('invalid') == -1) {
  44.                 var results = http.responseText.split(",");
  45.                 numTarea = results[0];
  46.                 enProceso = false;                
  47.             }
  48.         }
  49.     }
  50.    
  51. }

Código HTML:
Ver original
  1. for (i=0;i<10;i++){
  2.    
  3.    verificaUsuario(i)
  4.  
  5.    document.write(numTarea);
  6.  
  7.    document.write(i);
  8.  
  9. }


En la página ajax.aspx está saliendo bien el resultado. El problema es que no entra en
Código Javascript:
Ver original
  1. if (http.status == 200) {
  2.            
  3.             if (http.responseText.indexOf('invalid') == -1) {
  4.                 var results = http.responseText.split(",");
  5.                 numTarea = results[0];
  6.                 enProceso = false;                
  7.             }
  8.         }

Alguna idea?