Hi, Does anyone know why Prototype invokes the Ajax.Responders onComplete method on IE and FireFox but not on Safari when Ajax.Request is aborted by invoking the transport.abort() method? (Is it a bug for Safari not implementing the XMLHttpRequest object correctly?) If I invoke the transport.abort(), it screws up the Ajax.activeRequestCount on Safari since Ajax.Responders onComplete is not invoked. Please let me know if there is a work around for this or if there is a better way of aborting Ajax request. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
This happens because onTimeout never fires on Safari which updates the
activeRequestCount.
Instead of invoking abort on transport directly you can extend the
Ajax.Request class with the following method. It takes care of calling
onTimeout for Safari thus updating the activeRequestCount.
Ajax.Request.prototype.abortRequest = function() {
this.aborted = true;
this.transport.abort();
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
(this.options[''onTimeout''] || Prototype.emptyFunction)();
}
}
Just paste the code anywhere after your prototype.js include.
Usage:
var myReq = new Ajax.Request(blah..blah..);
myReq.abortRequest();
-----Original Message-----
From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf
Of Satoru
Moriwaki
Sent: Thursday, June 19, 2008 2:18 PM
To: Ruby on Rails: Spinoffs
Subject: [Rails-spinoffs] Aborting Ajax request
Hi,
Does anyone know why Prototype invokes the Ajax.Responders onComplete
method on IE and FireFox but not on Safari when Ajax.Request is
aborted by invoking the transport.abort() method? (Is it a bug for
Safari not implementing the XMLHttpRequest object correctly?)
If I invoke the transport.abort(), it screws up the
Ajax.activeRequestCount on Safari since Ajax.Responders onComplete is
not invoked.
Please let me know if there is a work around for this or if there is a
better way of aborting Ajax request.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks for the tip. I tried it right away, but it didn''t work (do I
have to implement onTimeout callback to decrement
Ajax.activeRequestCount?)
I did the following and it seems working fine.
...
...
...
this._request.transport.abort();
// for Opera and Safari
if(Prototype.Browser.Opera || Prototype.Browser.WebKit)
{
Ajax.activeRequestCount--;
}
On Jun 19, 6:43 pm, "Irfan, Ghouseuddin Syed"
<is...-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org>
wrote:> This happens because onTimeout never fires on Safari which updates the
> activeRequestCount.
>
> Instead of invoking abort on transport directly you can extend the
> Ajax.Request class with the following method. It takes care of calling
> onTimeout for Safari thus updating the activeRequestCount.
>
> Ajax.Request.prototype.abortRequest = function() {
> this.aborted = true;
> this.transport.abort();
> if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
> (this.options[''onTimeout''] ||
Prototype.emptyFunction)();
> }
>
> }
>
> Just paste the code anywhere after your prototype.js include.
>
> Usage:
>
> var myReq = new Ajax.Request(blah..blah..);
> myReq.abortRequest();
>
> -----Original Message-----
> From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>
> [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On
Behalf Of Satoru
> Moriwaki
> Sent: Thursday, June 19, 2008 2:18 PM
> To: Ruby on Rails: Spinoffs
> Subject: [Rails-spinoffs] Aborting Ajax request
>
> Hi,
>
> Does anyone know why Prototype invokes the Ajax.Responders onComplete
> method on IE and FireFox but not on Safari when Ajax.Request is
> aborted by invoking the transport.abort() method? (Is it a bug for
> Safari not implementing the XMLHttpRequest object correctly?)
>
> If I invoke the transport.abort(), it screws up the
> Ajax.activeRequestCount on Safari since Ajax.Responders onComplete is
> not invoked.
>
> Please let me know if there is a work around for this or if there is a
> better way of aborting Ajax request.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Yes that should work.
You can even try the following:
Ajax.Request.prototype.abortRequest = function() {
this.transport.abort();
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
Ajax.activeRequestCount--;
}
}
or
Ajax.Request.prototype.abortRequest = function() {
this.transport.abort();
if(Prototype.Browser.Opera || Prototype.Browser.WebKit){
Ajax.activeRequestCount--;
}
}
-----Original Message-----
From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of Satoru Moriwaki
Sent: Thursday, June 19, 2008 3:29 PM
To: Ruby on Rails: Spinoffs
Subject: [Rails-spinoffs] Re: Aborting Ajax request
Thanks for the tip. I tried it right away, but it didn''t work (do I
have to implement onTimeout callback to decrement
Ajax.activeRequestCount?)
I did the following and it seems working fine.
...
...
...
this._request.transport.abort();
// for Opera and Safari
if(Prototype.Browser.Opera || Prototype.Browser.WebKit)
{
Ajax.activeRequestCount--;
}
On Jun 19, 6:43 pm, "Irfan, Ghouseuddin Syed"
<is...-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org>
wrote:> This happens because onTimeout never fires on Safari which updates the
> activeRequestCount.
>
> Instead of invoking abort on transport directly you can extend the
> Ajax.Request class with the following method. It takes care of calling
> onTimeout for Safari thus updating the activeRequestCount.
>
> Ajax.Request.prototype.abortRequest = function() {
> this.aborted = true;
> this.transport.abort();
> if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
> (this.options[''onTimeout''] ||
Prototype.emptyFunction)();
> }
>
> }
>
> Just paste the code anywhere after your prototype.js include.
>
> Usage:
>
> var myReq = new Ajax.Request(blah..blah..);
> myReq.abortRequest();
>
> -----Original Message-----
> From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>
> [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On
Behalf Of Satoru
> Moriwaki
> Sent: Thursday, June 19, 2008 2:18 PM
> To: Ruby on Rails: Spinoffs
> Subject: [Rails-spinoffs] Aborting Ajax request
>
> Hi,
>
> Does anyone know why Prototype invokes the Ajax.Responders onComplete
> method on IE and FireFox but not on Safari when Ajax.Request is
> aborted by invoking the transport.abort() method? (Is it a bug for
> Safari not implementing the XMLHttpRequest object correctly?)
>
> If I invoke the transport.abort(), it screws up the
> Ajax.activeRequestCount on Safari since Ajax.Responders onComplete is
> not invoked.
>
> Please let me know if there is a work around for this or if there is a
> better way of aborting Ajax request.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks for the another tip. I''m wondering why Prototypejs doesn''t officially support the abort() method.... I think a lot of people need this right? But anyways, thanks again. Satoru On Jun 19, 7:16 pm, "Irfan, Ghouseuddin Syed" <is...-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> Yes that should work. > > You can even try the following: > > Ajax.Request.prototype.abortRequest = function() { > this.transport.abort(); > if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){ > Ajax.activeRequestCount--; > } > > } > > or > > Ajax.Request.prototype.abortRequest = function() { > this.transport.abort(); > if(Prototype.Browser.Opera || Prototype.Browser.WebKit){ Ajax.activeRequestCount--; > } > > } > -----Original Message----- > From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of Satoru Moriwaki > Sent: Thursday, June 19, 2008 3:29 PM > To: Ruby on Rails: Spinoffs > Subject: [Rails-spinoffs] Re: Aborting Ajax request > > Thanks for the tip. I tried it right away, but it didn''t work (do I > have to implement onTimeout callback to decrement > Ajax.activeRequestCount?) > > I did the following and it seems working fine. > > ... > ... > ... > this._request.transport.abort(); > > // for Opera and Safari > if(Prototype.Browser.Opera || Prototype.Browser.WebKit) > { > Ajax.activeRequestCount--; > } > > On Jun 19, 6:43 pm, "Irfan, Ghouseuddin Syed" <is...-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> > wrote: > > This happens because onTimeout never fires on Safari which updates the > > activeRequestCount. > > > Instead of invoking abort on transport directly you can extend the > > Ajax.Request class with the following method. It takes care of calling > > onTimeout for Safari thus updating the activeRequestCount. > > > Ajax.Request.prototype.abortRequest = function() { > > this.aborted = true; > > this.transport.abort(); > > if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){ > > (this.options[''onTimeout''] || Prototype.emptyFunction)(); > > } > > > } > > > Just paste the code anywhere after your prototype.js include. > > > Usage: > > > var myReq = new Ajax.Request(blah..blah..); > > myReq.abortRequest(); > > > -----Original Message----- > > From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > > [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Satoru > > Moriwaki > > Sent: Thursday, June 19, 2008 2:18 PM > > To: Ruby on Rails: Spinoffs > > Subject: [Rails-spinoffs] Aborting Ajax request > > > Hi, > > > Does anyone know why Prototype invokes the Ajax.Responders onComplete > > method on IE and FireFox but not on Safari when Ajax.Request is > > aborted by invoking the transport.abort() method? (Is it a bug for > > Safari not implementing the XMLHttpRequest object correctly?) > > > If I invoke the transport.abort(), it screws up the > > Ajax.activeRequestCount on Safari since Ajax.Responders onComplete is > > not invoked. > > > Please let me know if there is a work around for this or if there is a > > better way of aborting Ajax request.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---