Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.javascript > #7944

Re: Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante.

From Alessandro Pellizzari <shuriken@amiran.it>
Newsgroups it.comp.lang.javascript
Subject Re: Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante.
Date 2015-12-16 20:19 +0000
Message-ID <dddvasFinb3U1@mid.individual.net> (permalink)
References <n4r8k7$ob0$1@speranza.aioe.org>

Show all headers | View raw


Il Wed, 16 Dec 2015 09:50:13 +0100, GriS ha scritto:

> Al momento, lo spinner è gestito così:
> 
> $("#spinner").bind("ajaxSend", function() {
> $(this).show();
> }).bind("ajaxStop", function() {
> $(this).hide();
> }).bind("ajaxError", function() {
> $(this).hide();
> });

Non ho mai usato questi eventi, ma stando alla documentazione di jQuery 
vengono lanciati su document, non su elementi del DOM. Probabilmente li 
catturi grazie al bubbling, ma non so cosa sia il this in quel caso.

Io farei così:

$(document)
  .on('ajaxStart', function() {
    $('#spinner').show();
  })
  .on('ajaxStop', function() {
    $('#spinner').hide();
  })
;

Dovrebbero bastare questi due, in teoria.

Bye.

Back to it.comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante. GriS <GriS@nospam.no> - 2015-12-16 09:50 +0100
  Re: Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante. Alessandro Pellizzari <shuriken@amiran.it> - 2015-12-16 20:19 +0000
    Re: Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante. GriS <GriS@nospam.no> - 2015-12-17 12:02 +0100

csiph-web