Path: csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: GriS Newsgroups: it.comp.lang.javascript Subject: Re: Gestione eventi ajax (ajaxStop, ajaxError etc...) non sempre funzionante. Date: Thu, 17 Dec 2015 12:02:34 +0100 Organization: Aioe.org NNTP Server Lines: 38 Message-ID: References: NNTP-Posting-Host: 1EYKSE0oo3A8XWyQY7G6kA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com it.comp.lang.javascript:7945 Grazie per la risposta, proverò il tuo codice anche se non ho capito, ajaxStop non credo che gestisca anche l'error, o sbaglio? Grazie ancora. Il 16/12/2015 21.19, Alessandro Pellizzari ha scritto: > 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. >