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

.net cargadorContenidos

Estas en el tema de .net cargadorContenidos en el foro de Frameworks JS en Foros del Web. MUY BUENAS COMPAÑEROS miren les explico: estoy utilizando el siguiente objecto, pero no hay manera de que me funcione nose que es lo que hago ...
  #1 (permalink)  
Antiguo 18/01/2011, 03:28
 
Fecha de Ingreso: septiembre-2007
Mensajes: 152
Antigüedad: 16 años, 7 meses
Puntos: 1
.net cargadorContenidos

MUY BUENAS COMPAÑEROS


miren les explico: estoy utilizando el siguiente objecto, pero no hay manera de que me funcione nose que es lo que hago mal

Me podrian escribir un simple exemplo de como crear un objecto con new.. y que parametros pasarle y como, (Ya que lo he hecho y no me funciona !!! ) ademas de la funcion respuesta que yo le digo que introduzca en un DIV el contenido de un file php y no lo hace da readyState 0 etc..etc.. ,, muchas gracias de antemano..


Código Javascript:
Ver original
  1. var net = new Object();
  2.  
  3. net.READY_STATE_UNINITIALIZED=0;
  4. net.READY_STATE_LOADING=1;
  5. net.READY_STATE_LOADED=2;
  6. net.READY_STATE_INTERACTIVE=3;
  7. net.READY_STATE_COMPLETE=4;
  8.  
  9. // Constructor
  10. net.CargadorContenidos = function(url, funcion, funcionError, metodo, parametros, contentType) {
  11.   this.url = url;
  12.   this.req = null;
  13.   this.onload = funcion;
  14.   this.onerror = (funcionError) ? funcionError : this.defaultError;
  15.   this.cargaContenidoXML(url, metodo, parametros, contentType);
  16. }
  17.  
  18. net.CargadorContenidos.prototype = {
  19.   cargaContenidoXML: function(url, metodo, parametros, contentType) {
  20.     if(window.XMLHttpRequest) {
  21.       this.req = new XMLHttpRequest();
  22.     }
  23.     else if(window.ActiveXObject) {
  24.       this.req = new ActiveXObject("Microsoft.XMLHTTP");
  25.     }
  26.  
  27.     if(this.req) {
  28.       try {
  29.         var loader = this;
  30.         this.req.onreadystatechange = function() {
  31.           loader.onReadyState.call(loader);
  32.         }
  33.         this.req.open(metodo, url, true);
  34.         if(contentType) {
  35.           this.req.setRequestHeader("Content-Type", contentType);
  36.         }
  37.         this.req.send(parametros);
  38.         } catch(err) {
  39.           this.onerror.call(this);
  40.         }
  41.     }
  42.   },
  43.  
  44.   onReadyState: function() {
  45.     var req = this.req;
  46.     var ready = req.readyState;
  47.     if(ready == net.READY_STATE_COMPLETE) {
  48.       var httpStatus = req.status;
  49.       if(httpStatus == 200 || httpStatus == 0) {
  50.         this.onload.call(this);
  51.       }
  52.       else {
  53.         this.onerror.call(this);
  54.       }
  55.     }
  56.   },
  57.  
  58.   defaultError: function() {
  59.     alert("Se ha producido un error al obtener los datos"
  60.       + "\n\nreadyState:" + this.req.readyState
  61.       + "\nstatus: " + this.req.status
  62.       + "\nheaders: " + this.req.getAllResponseHeaders());
  63.   }
  64. }

Un saludo

Última edición por darkram; 18/01/2011 a las 04:27

Etiquetas: ajax, .net
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 01:16.