xhr? returns false if using Firefox or Opera, but at the same time it returns true if the same request was made using Internet Explorer Any ideas? Bogdan _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Are you using request.xhr? or @request.xhr? I have no problems with request.xhr? - Derek On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> xhr? returns false if using Firefox or Opera, but at the same time it > returns true if the same request was made using Internet Explorer > Any ideas? > > Bogdan > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Derek Haynes HighGroove Studios - http://www.highgroove.com Keeping it Simple. 404.593.4879
Im having no probs either...ff and safari on mac... Mikkel On 24/09/2005, at 21.51, Derek Haynes wrote:> Are you using request.xhr? or @request.xhr? I have no problems with > request.xhr? > > - Derek > > On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> xhr? returns false if using Firefox or Opera, but at the same time it >> returns true if the same request was made using Internet Explorer >> Any ideas? >> >> Bogdan >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> > > > -- > Derek Haynes > HighGroove Studios - http://www.highgroove.com > Keeping it Simple. > 404.593.4879 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Bogdan, I am using: request.xhr? It works for me for both IE 6 and Firefox 1.07. Tom On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> xhr? returns false if using Firefox or Opera, but at the same time it > returns true if the same request was made using Internet Explorer > Any ideas? > > Bogdan > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Ok, I was able to reproduce that case when xhr? is not working in Firefox and Opera Assume this: def action1 # request.xhr? is true here redirect_to(:action=>''action2'') end def action2 #request.xhr? returns false for firefox and opera, but NOT for IE end Bogdan On 9/25/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Bogdan, > > I am using: request.xhr? > > It works for me for both IE 6 and Firefox 1.07. > > Tom > > On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > xhr? returns false if using Firefox or Opera, but at the same time it > > returns true if the same request was made using Internet Explorer > > Any ideas? > > > > Bogdan > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
OK. That makes sense because the redirect is actually performing an HTML redirect, which resends the headers and everything. Therefore, the redirect is no longer an AJAX request, it is just an HTML redirect. You should try to design your AJAX actions so a redirect is not required. In my case, I have the normal HTTP request cause a redirect and the AJAX to just render nothing like this: if !request.xhr? redirect_to :action => :index else render :nothing end Good luck, Tom On 9/25/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ok, I was able to reproduce that case when xhr? is not working in Firefox > and Opera > Assume this: > > > def action1 > # request.xhr? is true here > redirect_to(:action=>''action2'') > end > > def action2 > #request.xhr? returns false for firefox and opera, but NOT for IE > end > > > Bogdan > > > > On 9/25/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > Hi Bogdan, > > > > I am using: request.xhr? > > > > It works for me for both IE 6 and Firefox 1.07. > > > > Tom > > > > On 9/24/05, Bogdan Ionescu < bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > xhr? returns false if using Firefox or Opera, but at the same time it > > > returns true if the same request was made using Internet Explorer > > > Any ideas? > > > > > > Bogdan > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Without too much investigation, this sounds like a bug (or a diffrent approach?) in Firefox vs. IE on handling redirect in the XMLHttpRequest object, where Firefox doesn''t attach custom HTTP headers to the second call in XMLHttpRequest. A quick search on bugzilla.mozilla.org didn''t turn anything up on that. It''s probably safer not to rely on redirects in AJAX-called actions for the time being. Thomas Am 25.09.2005 um 15:07 schrieb Bogdan Ionescu:> Ok, I was able to reproduce that case when xhr? is not working in > Firefox and Opera > Assume this: > > def action1 > # request.xhr? is true here > redirect_to(:action=>''action2'') > end > > def action2 > #request.xhr? returns false for firefox and opera, but NOT for IE > end