Ver Mensaje Individual
  #12 (permalink)  
Antiguo 06/02/2011, 18:40
Avatar de portalmana
portalmana
 
Fecha de Ingreso: septiembre-2007
Ubicación: Montevideo-Uruguay
Mensajes: 633
Antigüedad: 16 años, 7 meses
Puntos: 80
Respuesta: Llego Jquery 1.5

Cita:
Iniciado por maycolalvarez Ver Mensaje
para implementar comet podrias buscar algún plugin, pero básicamente la técnica del long polling es lo más rápido de implementar
Lo que encontre es esto:
Código Javascript:
Ver original
  1. jQuery.comet = {
  2.  
  3.     fetching: false,
  4.     settings: {},
  5.     url: '',
  6.     bound: {},
  7.     connect: function(url, options) {
  8.         jQuery.comet.settings = jQuery.extend({
  9.             timeout: 60000,
  10.             onError: null,
  11.             requestMethod: 'GET',
  12.             typeAttr: 'type',
  13.             dataAttr: 'data'
  14.         }, options);
  15.         jQuery.comet.url = url;
  16.         jQuery.comet.fetch();
  17.     },
  18.  
  19.     fetch: function() {
  20.         if (jQuery.comet.fetching)
  21.             return;
  22.  
  23.         jQuery.comet.fetching = true;
  24.         $.ajax({
  25.             type: jQuery.comet.settings.requestMethod,
  26.             url: jQuery.comet.url,
  27.  
  28.             async: true,
  29.             cache: true,
  30.             timeout: jQuery.comet.settings.timeout,
  31.             ifModified: true,
  32.  
  33.             success: function(data) {
  34.                 jQuery.comet.fetching = false;
  35.                 jQuery.comet.handle_update(data);
  36.                 setTimeout(jQuery.comet.fetch, 1);
  37.             },
  38.             error: function(XMLHttpRequest, textStatus, errorThrown) {
  39.                 jQuery.comet.fetching = false;
  40.                 if (textStatus == 'timeout') {
  41.                     jQuery.comet.fetch()
  42.                 } else {
  43.                     if (jQuery.comet.settings.onError != null) {
  44.                         jQuery.comet.settings.onError(XMLHttpRequest, textStatus, errorThrown);
  45.                     }
  46.                     setTimeout(jQuery.comet.fetch, 10000);
  47.                 }
  48.  
  49.             }
  50.         });
  51.     },
  52.  
  53.     handle_update: function(update) {
  54.         type = null;
  55.         data = update;
  56.  
  57.         if (update[jQuery.comet.settings.typeAttr]) {
  58.             type = update[jQuery.comet.settings.typeAttr];
  59.         }
  60.         if (update[jQuery.comet.settings.dataAttr]) {
  61.             data = update[jQuery.comet.settings.dataAttr];
  62.         }
  63.  
  64.         jQuery(document).trigger(type + ".comet", [data, type]);
  65.     }
  66. };
Que te parece, puede ser útil...
Saludos y gracias por responder
__________________
"La imaginación es más importante que el conocimiento. El conocimiento es limitado, mientras que la imaginación no" -- A.Einstein
objetivophp.com,twitter.com/objetivophp