heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-03 01:11 UTC
Opera and responseText Not working
I have some really simple ajax code that makes a post and then reads the result. Now IE7 IE6 Firefox and Safari all work... however opera returns "" for responseText. I have tried flushing the buffer, different head responses etc but its just doesnt return anything... is this a possible bug in the new opera version (9.10)? new Ajax.Request(window.location, { method: "post", postBody: "pageAction=login" + "&username=" + escape($ ("username").value) + "&password=" + escape($("password").value), onSuccess: function(e) { document.location=document.location; }, onFailure: function(e) { alert("tesT:" + e.responseText); } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Opera 9.10 works fine with Prototype''s Ajax.Request. However, in your code it looks like you are checking for responseText inside the onFailure function. Since that function is only called on failure, I wouldn''t expect there to be any responseText. I could be wrong since honestly I never use the onFailure function... :-o It sounds like maybe what you want to use are functions for specific failure codes, like on404, etc.. If you are still having problems, I''d check two things: 1) The server is getting the request you think it''s getting and the browser is getting the response you think it''s getting. Perhaps use a tool like SoftX HTTP Debugger (http://www.softx.org/debugger.html) to inspect the request and response outside the scope of the browser. 2) The code executed on response isn''t throwing an exception. The onXXX functions will often give no indication if there is an error in the code that halts execution. Use some code like this to capture those exceptions: function getExceptionDetails(ex){ var message ''<b>''+ex.name+'':</b><pre>''+ex.message+''</pre><br/>''+ (ex.fileName && ex.lineNumber ? ex.fileName+'' (line <b>''+ex.lineNumber+''</b>)<br/><br/>'':'''')+ (ex.description ? ''Description:<pre>''+ex.description+''</pre><br/>'':'''')+ (ex.stack ? ''Stack trace: <pre>''+ex.stack+''</pre><br/>'':'''')+ (ex.number ? ''Number: ''+ex.number+''<br/>'':'''')+ (ex[''opera#sourceloc''] ? ''Location: <b>''+ex[''opera#sourceloc'']+''</b><br/>'':''''); return message; } Ajax.Responders.register({ onException: function(request,ex){ new Insertion.Bottom(''debug'',''<hr/><br/>''+getExceptionDetails(ex)+''<br/><br/>''); } }); Colin heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I have some really simple ajax code that makes a post and then reads > the result. Now IE7 IE6 Firefox and Safari all work... however opera > returns "" for responseText. I have tried flushing the buffer, > different head responses etc but its just doesnt return anything... is > this a possible bug in the new opera version (9.10)? > > new Ajax.Request(window.location, { method: "post", > postBody: "pageAction=login" + "&username=" + escape($ > ("username").value) + "&password=" + escape($("password").value), > onSuccess: function(e) { > document.location=document.location; > }, > onFailure: function(e) { > alert("tesT:" + e.responseText); > } > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :> new Ajax.Request(window.location, { method: "post", > postBody: "pageAction=login" + "&username=" + escape($ > ("username").value) + "&password=" + escape($("password").value), > onSuccess: function(e) { > document.location=document.location; > }, > onFailure: function(e) { > alert("tesT:" + e.responseText); > }What I find absolutely fascinating with this code is that you seem to use AJAX in order to achieve non-AJAX processing: once your AJAX request succeeds, you reload the page (and with a rather devious JS line at that!)... I mean, the best way to do that is through a simple, vanilla POST request (e.g. through a form) to the server side, which returns a HTTP Location header on success... -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, For our website we have implemented already ages ago a simple cross browser chat solution using an endless-loading php page. As we migrate the whole pages now we were looking for a basic ajax chat solution to build upon. Writing from scratch would be also fun but I think not reinventing the wheel would be better. There is a nice comparison on http://ajax.phpmagazine.net/2006/02/ajax_powered_chat_applications.html but what we would need is even simpler. As said nothing that I couldn''t do myself (e.g. using periodically updaters) but if anybody knows some simple: "input via ajax into db, ajax polls every second the database and adds new entrys from the db to the chat output" solution I would appreciate it .: Fabian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Feb-03 13:43 UTC
Re: Anybody knows of a prototype/sau based chat solution
Hey Fabian, I guess this won''t do it for you, as you may be bent on in-site integration, but wouldn''t a Campfire subscription by any chance suit your needs? -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fabian Lange
2007-Feb-03 15:44 UTC
Re: Anybody knows of a prototype/sau based chat solution
Okay, this was much simpler than expected. SO ill share it :) I need two divs: one called chat. The other one called ts. Its holding a timestamp when the last update was made. <script type="text/javascript"> //<![CDATA[ new PeriodicalExecuter(function() { new Ajax.Request(''/chat/get'', {asynchronous:true, evalScripts:false, onComplete:function(request, json){updateJSON(request, json)}, parameters:''ts='' + $(''ts'').innerHTML})}, 10) //]]> var chat = $(''chat''); function updateJSON(request, json) { var nbElementsInResponse = json.length; for (var i = 0; i < nbElementsInResponse; i++){ if (json[i][0] == ''c'') { var doScroll = false; if(chat.scrollTop == (chat.scrollHeight - 200)){ doScroll = true} Element.update(chat, chat.innerHTML + json[i][1]); if(doScroll){ chat.scrollTop = chat.scrollHeight } } else { Element.update(json[i][0], json[i][1]); } } } //]]> </script> The get serverside action will check if there are new messages to deliver. If that''s the case its put into json. And ts is updated to a new timestamp. To input data <form onsubmit="new Ajax.Request(''/chat/send'', {asynchronous:true, evalScripts:false, onComplete:function(request, json){updateJSON(request, json);$(''message'').value='''';$(''go'').disabled=false}, onLoading:function(request, json){$(''go'').disabled=true}, parameters:Form.serialize(this)}); return false;" action="/chat/send" method="post"> <input type="text" name="message" id="message" value="" /> <input type="submit" name="commit" value="Go" id="go" /> </form> The send action on the server will just add the message into the database or memory and then directly call the get action described above Quite neat. And rapid to prototype. Now the finetuning will start. Comments always welcome .: Fabian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jerod Venema
2007-Feb-04 01:48 UTC
Re: Anybody knows of a prototype/sau based chat solution
If you want to implement something a little more robust, I suggest: 1) Grab ejabberd (http://www.process-one.net/en/ejabberd/) as a full-featured jabber chat server 2) Implement the proper jabber protocol. Two good options: a) Grab JWChat (http://jwchat.sourceforge.net/) for the full chat client or, b) Grab JSJaC (http://jsjac.jabberstudio.org/) for just the underlying communication library Probably a little more work, but it''s already a full-featured, open-souce, open-protocol chat client that way, and would potentially work with thick clients as well, if that interests you... -Jerod On 2/3/07, Fabian Lange <Fabian.Lange-S0/GAf8tV78@public.gmane.org> wrote:> > > Okay, > this was much simpler than expected. > SO ill share it :) > > I need two divs: one called chat. The other one called ts. Its holding a > timestamp when the last update was made. > > > <script type="text/javascript"> > //<![CDATA[ > new PeriodicalExecuter(function() { > new Ajax.Request(''/chat/get'', > {asynchronous:true, evalScripts:false, > onComplete:function(request, json){updateJSON(request, json)}, > parameters:''ts='' + $(''ts'').innerHTML})}, 10) > //]]> > > var chat = $(''chat''); > function updateJSON(request, json) > { > var nbElementsInResponse = json.length; > for (var i = 0; i < nbElementsInResponse; i++){ > if (json[i][0] == ''c'') { > var doScroll = false; > if(chat.scrollTop == (chat.scrollHeight - 200)){ doScroll = true} > Element.update(chat, chat.innerHTML + json[i][1]); > if(doScroll){ chat.scrollTop = chat.scrollHeight } > } else { > Element.update(json[i][0], json[i][1]); > } > } > } > //]]> > </script> > > The get serverside action will check if there are new messages to deliver. > If that''s the case its put into json. And ts is updated to a new > timestamp. > > To input data > <form onsubmit="new Ajax.Request(''/chat/send'', > {asynchronous:true, evalScripts:false, > onComplete:function(request, json){updateJSON(request, > json);$(''message'').value='''';$(''go'').disabled=false}, > onLoading:function(request, json){$(''go'').disabled=true}, > parameters:Form.serialize(this)}); return false;" action="/chat/send" > method="post"> > > <input type="text" name="message" id="message" value="" /> > <input type="submit" name="commit" value="Go" id="go" /> > </form> > > > The send action on the server will just add the message into the database > or > memory and then directly call the get action described above > > Quite neat. And rapid to prototype. Now the finetuning will start. > Comments > always welcome > > .: Fabian > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-05 21:47 UTC
Re: Opera and responseText Not working
Ok i have narrowed it down, when I make an ajax post the page im posting to returns a header and some data. For example if the login was successfuly I may return the session ID or something like that with a header of 200. If the login failed I may return an error code with a header of 400. Now for some reason opera does not get a responseText for anything except 200. I think this is an opera only bug as it works in every other browsers. On Feb 2, 7:55 pm, Colin Mollenhour <eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> Opera 9.10 works fine with Prototype''s Ajax.Request. However, in your > code it looks like you are checking for responseText inside the > onFailure function. Since that function is only called on failure, I > wouldn''t expect there to be any responseText. I could be wrong since > honestly I never use the onFailure function... :-o It sounds like maybe > what you want to use are functions for specific failure codes, like > on404, etc.. > > If you are still having problems, I''d check two things: > > 1) The server is getting the request you think it''s getting and the > browser is getting the response you think it''s getting. Perhaps use a > tool like SoftX HTTP Debugger (http://www.softx.org/debugger.html) to > inspect the request and response outside the scope of the browser. > > 2) The code executed on response isn''t throwing an exception. The onXXX > functions will often give no indication if there is an error in the code > that halts execution. Use some code like this to capture those exceptions: > > function getExceptionDetails(ex){ > var message > ''<b>''+ex.name+'':</b><pre>''+ex.message+''</pre><br/>''+ > (ex.fileName && ex.lineNumber ? ex.fileName+'' (line > <b>''+ex.lineNumber+''</b>)<br/><br/>'':'''')+ > (ex.description ? ''Description:<pre>''+ex.description+''</pre><br/>'':'''')+ > (ex.stack ? ''Stack trace: <pre>''+ex.stack+''</pre><br/>'':'''')+ > (ex.number ? ''Number: ''+ex.number+''<br/>'':'''')+ > (ex[''opera#sourceloc''] ? ''Location: > <b>''+ex[''opera#sourceloc'']+''</b><br/>'':''''); > return message;} > > Ajax.Responders.register({ > onException: function(request,ex){ > new > Insertion.Bottom(''debug'',''<hr/><br/>''+getExceptionDetails(ex)+''<br/><br/>''); > } > > }); > > Colin > > heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > I have some really simple ajax code that makes a post and then reads > > the result. Now IE7 IE6 Firefox and Safari all work... however opera > > returns "" for responseText. I have tried flushing the buffer, > > different head responses etc but its just doesnt return anything... is > > this a possible bug in the new opera version (9.10)? > > > new Ajax.Request(window.location, { method: "post", > > postBody: "pageAction=login" + "&username=" + escape($ > > ("username").value) + "&password=" + escape($("password").value), > > onSuccess: function(e) { > > document.location=document.location; > > }, > > onFailure: function(e) { > > alert("tesT:" + e.responseText); > > }--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-05 21:48 UTC
Re: Opera and responseText Not working
Dont worry about that. Its a simple solution for a framework constraint. I know when and when not to make a standard post. But thank you for your input. On Feb 3, 3:27 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit : > > > new Ajax.Request(window.location, { method: "post", > > postBody: "pageAction=login" + "&username=" + escape($ > > ("username").value) + "&password=" + escape($("password").value), > > onSuccess: function(e) { > > document.location=document.location; > > }, > > onFailure: function(e) { > > alert("tesT:" + e.responseText); > > } > > What I find absolutely fascinating with this code is that you seem to > use AJAX in order to achieve non-AJAX processing: once your AJAX request > succeeds, you reload the page (and with a rather devious JS line at > that!)... > > I mean, the best way to do that is through a simple, vanilla POST > request (e.g. through a form) to the server side, which returns a HTTP > Location header on success... > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> A test page would be nice so that I could test it firsthand, but my only other suggestion without seeing it for myself would be to use the X-JSON header for your error codes. If Opera or Prototype does in fact have a problem with responseText in your case, then the X-JSON header will probably still work. I played with this once and can''t remember if I tested in Opera or not... It isn''t really a fix but it will let you accomplish what you wanted to. You could also use any other custom header if necessary but be aware of the header size limitations.<br> <br> Colin<br> <br> <a class="moz-txt-link-abbreviated" href="mailto:heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a> wrote: <blockquote cite="mid:1170712035.558160.211210-xVE043aoV8kPJnSzqDEE6GB/v6IoIuQBVpNB7YpNyf8@public.gmane.org" type="cite"> <pre wrap="">Ok i have narrowed it down, when I make an ajax post the page im posting to returns a header and some data. For example if the login was successfuly I may return the session ID or something like that with a header of 200. If the login failed I may return an error code with a header of 400. Now for some reason opera does not get a responseText for anything except 200. I think this is an opera only bug as it works in every other browsers. On Feb 2, 7:55 pm, Colin Mollenhour <a class="moz-txt-link-rfc2396E" href="mailto:eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org"><eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">Opera 9.10 works fine with Prototype''s Ajax.Request. However, in your code it looks like you are checking for responseText inside the onFailure function. Since that function is only called on failure, I wouldn''t expect there to be any responseText. I could be wrong since honestly I never use the onFailure function... :-o It sounds like maybe what you want to use are functions for specific failure codes, like on404, etc.. If you are still having problems, I''d check two things: 1) The server is getting the request you think it''s getting and the browser is getting the response you think it''s getting. Perhaps use a tool like SoftX HTTP Debugger (<a class="moz-txt-link-freetext" href="http://www.softx.org/debugger.html">http://www.softx.org/debugger.html</a>) to inspect the request and response outside the scope of the browser. 2) The code executed on response isn''t throwing an exception. The onXXX functions will often give no indication if there is an error in the code that halts execution. Use some code like this to capture those exceptions: function getExceptionDetails(ex){ var message ''<b>''+ex.name+'':</b><pre>''+ex.message+''</pre><br/>''+ (ex.fileName && ex.lineNumber ? ex.fileName+'' (line <b>''+ex.lineNumber+''</b>)<br/><br/>'':'''')+ (ex.description ? ''Description:<pre>''+ex.description+''</pre><br/>'':'''')+ (ex.stack ? ''Stack trace: <pre>''+ex.stack+''</pre><br/>'':'''')+ (ex.number ? ''Number: ''+ex.number+''<br/>'':'''')+ (ex[''opera#sourceloc''] ? ''Location: <b>''+ex[''opera#sourceloc'']+''</b><br/>'':''''); return message;} Ajax.Responders.register({ onException: function(request,ex){ new Insertion.Bottom(''debug'',''<hr/><br/>''+getExceptionDetails(ex)+''<br/><br/>'')­; } }); Colin <a class="moz-txt-link-abbreviated" href="mailto:heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a> wrote: </pre> <blockquote type="cite"> <pre wrap="">I have some really simple ajax code that makes a post and then reads the result. Now IE7 IE6 Firefox and Safari all work... however opera returns "" for responseText. I have tried flushing the buffer, different head responses etc but its just doesnt return anything... is this a possible bug in the new opera version (9.10)? </pre> </blockquote> <blockquote type="cite"> <pre wrap="">new Ajax.Request(window.location, { method: "post", postBody: "pageAction=login" + "&username=" + escape($ ("username").value) + "&password=" + escape($("password").value), onSuccess: function(e) { document.location=document.location; }, onFailure: function(e) { alert("tesT:" + e.responseText); } </pre> </blockquote> </blockquote> <pre wrap=""><!----> </pre> </blockquote> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-14 18:41 UTC
Re: Opera and responseText Not working
Here is a sample... note it works fine with every browsers except opera on non 200 responses. Php code is included in the pre tag. http://titan.clunet.edu/test.php On Feb 5, 2:33 pm, Colin Mollenhour <eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> A test page would be nice so that I could test it firsthand, but my only other suggestion without seeing it for myself would be to use the X-JSON header for your error codes. If Opera or Prototype does in fact have a problem with responseText in your case, then the X-JSON header will probably still work. I played with this once and can''t remember if I tested in Opera or not... It isn''t really a fix but it will let you accomplish what you wanted to. You could also use any other custom header if necessary but be aware of the header size limitations. > Colinheispsychotic-Re5JQEeQqe8M+Je31mqbdw@public.gmane.org:Ok i have narrowed it down, when I make an ajax post the page im posting to returns a header and some data. For example if the login was successfuly I may return the session ID or something like that with a header of 200. If the login failed I may return an error code with a header of 400. Now for some reason opera does not get a responseText for anything except 200. I think this is an opera only bug as it works in every other browsers. On Feb 2, 7:55 pm, Colin Mollenhour<eliteii...@mollenhour.com>wrote:Opera 9.10 works fine with Prototype''s Ajax.Request. However, in your code it looks like you are checking for responseText inside the onFailure function. Since that function is only called on failure, I wouldn''t expect there to be any responseText. I could be wrong since honestly I never use the onFailure function... :-o It sounds like maybe what you want to use are functions for specific failure codes, like on404, etc.. If you are still having problems, I''d check two things: 1) The server is getting the request you think it''s getting and the browser is getting the response you think it''s getting. Perhaps use a tool like SoftX HTTP Debugger (http://www.softx.org/debugger.html) to inspect the request and response outside the scope of the browser. 2) The code executed on response isn''t throwing an exception. The onXXX functions will often give no indication if there is an error in the code that halts execution. Use some code like this to capture those exceptions: function getExceptionDetails(ex){ var message = ''<b>''+ex.name+'':</b><pre>''+ex.message+''</pre><br/>''+ (ex.fileName && ex.lineNumber ? ex.fileName+'' (line <b>''+ex.lineNumber+''</b>)<br/><br/>'':'''')+ (ex.description ? ''Description:<pre>''+ex.description+''</pre><br/>'':'''')+ (ex.stack ? ''Stack trace: <pre>''+ex.stack+''</pre><br/>'':'''')+ (ex.number ? ''Number: ''+ex.number+''<br/>'':'''')+ (ex[''opera#sourceloc''] ? ''Location: <b>''+ex[''opera#sourceloc'']+''</b><br/>'':''''); return message;} Ajax.Responders.register({ onException: function(request,ex){ new Insertion.Bottom(''debug'',''<hr/><br/>''+getExceptionDetails(ex)+''<br/><br/>''); } }); Colinheispsycho...-Re5JQEeQqe8M+Je31mqbdw@public.gmane.org:I have some really simple ajax code that makes a post and then reads the result. Now IE7 IE6 Firefox and Safari all work... however opera returns "" for responseText. I have tried flushing the buffer, different head responses etc but its just doesnt return anything... is this a possible bug in the new opera version (9.10)?new Ajax.Request(window.location, { method: "post", postBody: "pageAction=login" + "&username=" + escape($ ("username").value) + "&password=" + escape($("password").value), onSuccess: function(e) { document.location=document.location; }, onFailure: function(e) { alert("tesT:" + e.responseText); }--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you for taking the time to post that test page. I haven''t tested this in any older version of Opera but it seems to be that Opera is quite behind on their Ajax support. I couldn''t find much info on it but this is definitely just an Opera limitation. I even hacked up the quirksmode Ajax functions and monitored every last detail of the XMLHttpRequest and Opera doesn''t follow a lot of the specs.. for example, on asynch calls it completely skips the Receiving (3) readyState. I also tried Content-Type: text/xml and neither the responseText nor responseXML are given any useful values for anything but 200. There''s nothing you can do about this other than write a patch for Opera and I have no idea where to start there.. However, a completely viable option would be to use a custom header. I tested this and Opera does set them and retrieve them correctly for all response statuses. You could use Prototype''s current JSON convention or make up your own... PHP: header(''X-JSON: ({"key":"Your value"})''); //Prototype already supports this header(''X-responseText: Some text here''); //make sure this is escape properly if necessary Javascript: onFailure: function(transport, json){ alert(json.key); //"Your value" var responseText = (transport.responseText ? transport.responseText : transport.getResponseHeader(''X-responseText'')); alert(responseText); } There is nothing Prototype can do about this and I don''t warrant any such hacks be implemented, I think you''ll just have to live with it until Opera gets their XMLHttpRequest support complete. I recommend the JSON approach as PHP has a nice json_encode and Prototype already supports it, all of your encoding will be handled for you. Colin heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Here is a sample... note it works fine with every browsers except > opera on non 200 responses. Php code is included in the pre tag. > > http://titan.clunet.edu/test.php > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-15 21:38 UTC
Re: Opera and responseText Not working
Wow glad to see that I''m not crazy =) I don''t really know if I want to create such a lengthy workaround in my application for Opera. I like the browsers but lets face it, almost no one uses it and if is not supporting Ajax properly then there isn''t much i am willing to do. I submitted a bug report to Opera but i think a lot of people are under the impressions that its a implementation issue due to some kind of browser checking in the code. I will leave that page on our servers in case you would like to submit another more detailed bug report as you seem to know a bit more about this than i do. Thanks again for you help. -Alex On Feb 14, 2:09 pm, Colin Mollenhour <eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> Thank you for taking the time to post that test page. I haven''t tested > this in any older version of Opera but it seems to be that Opera is > quite behind on their Ajax support. I couldn''t find much info on it but > this is definitely just an Opera limitation. I even hacked up the > quirksmode Ajax functions and monitored every last detail of the > XMLHttpRequest and Opera doesn''t follow a lot of the specs.. for > example, on asynch calls it completely skips the Receiving (3) > readyState. I also tried Content-Type: text/xml and neither the > responseText nor responseXML are given any useful values for anything > but 200. There''s nothing you can do about this other than write a patch > for Opera and I have no idea where to start there.. > > However, a completely viable option would be to use a custom header. I > tested this and Opera does set them and retrieve them correctly for all > response statuses. You could use Prototype''s current JSON convention or > make up your own... > PHP: > header(''X-JSON: ({"key":"Your value"})''); //Prototype already supports this > header(''X-responseText: Some text here''); //make sure this is escape > properly if necessary > > Javascript: > onFailure: function(transport, json){ > alert(json.key); //"Your value" > var responseText = (transport.responseText ? transport.responseText > : transport.getResponseHeader(''X-responseText'')); > alert(responseText); > > } > > There is nothing Prototype can do about this and I don''t warrant any > such hacks be implemented, I think you''ll just have to live with it > until Opera gets their XMLHttpRequest support complete. I recommend the > JSON approach as PHP has a nice json_encode and Prototype already > supports it, all of your encoding will be handled for you. > > Colin > > heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > Here is a sample... note it works fine with every browsers except > > opera on non 200 responses. Php code is included in the pre tag. > > >http://titan.clunet.edu/test.php--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> It''s too bad little things like this hold it back from being more usable, because I think Opera really is a great browser, better than IE and Safari in many ways and ahead of Firefox in some ways back in it''s 1.x days. It''s future lies mostly in handheld devices since it is so lightweight and renders so quickly and they seem to be focusing on that anyway. I''ve run into very few cases that I have to do anything special to get Opera to work, so if it is deployed widely on handheld and other non-PC/Mac devices there is a good reason to support it. It even has the small screen view (Shift+F11) available in the standard desktop version which would make development for handhelds even easier.<br> <br> Is Opera''s bug reporting system web-based? I''d like to watch the progress of it if you can give me a link or discussion board or something. I don''t really know much more than you about it, I just took your page and used quirksmode''s ajax example as a skeleton to make a *very* barebones request function that alerted each bit of progress during the request, not even loading the Prototype library at all to quell any doubts as to Prototype''s responsibility.<br> <br> Thanks,<br> Colin<br> <br> <a class="moz-txt-link-abbreviated" href="mailto:heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a> wrote: <blockquote cite="mid:1171575489.967160.292880-xVE043aoV8kPJnSzqDEE6GB/v6IoIuQBVpNB7YpNyf8@public.gmane.org" type="cite"> <pre wrap="">Wow glad to see that I''m not crazy =) I don''t really know if I want to create such a lengthy workaround in my application for Opera. I like the browsers but lets face it, almost no one uses it and if is not supporting Ajax properly then there isn''t much i am willing to do. I submitted a bug report to Opera but i think a lot of people are under the impressions that its a implementation issue due to some kind of browser checking in the code. I will leave that page on our servers in case you would like to submit another more detailed bug report as you seem to know a bit more about this than i do. Thanks again for you help. -Alex On Feb 14, 2:09 pm, Colin Mollenhour <a class="moz-txt-link-rfc2396E" href="mailto:eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org"><eliteii...-NPSFNn/7+NYVo650/ln6uw@public.gmane.org></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">Thank you for taking the time to post that test page. I haven''t tested this in any older version of Opera but it seems to be that Opera is quite behind on their Ajax support. I couldn''t find much info on it but this is definitely just an Opera limitation. I even hacked up the quirksmode Ajax functions and monitored every last detail of the XMLHttpRequest and Opera doesn''t follow a lot of the specs.. for example, on asynch calls it completely skips the Receiving (3) readyState. I also tried Content-Type: text/xml and neither the responseText nor responseXML are given any useful values for anything but 200. There''s nothing you can do about this other than write a patch for Opera and I have no idea where to start there.. However, a completely viable option would be to use a custom header. I tested this and Opera does set them and retrieve them correctly for all response statuses. You could use Prototype''s current JSON convention or make up your own... PHP: header(''X-JSON: ({"key":"Your value"})''); //Prototype already supports this header(''X-responseText: Some text here''); //make sure this is escape properly if necessary Javascript: onFailure: function(transport, json){ alert(json.key); //"Your value" var responseText = (transport.responseText ? transport.responseText : transport.getResponseHeader(''X-responseText'')); alert(responseText); } There is nothing Prototype can do about this and I don''t warrant any such hacks be implemented, I think you''ll just have to live with it until Opera gets their XMLHttpRequest support complete. I recommend the JSON approach as PHP has a nice json_encode and Prototype already supports it, all of your encoding will be handled for you. Colin <a class="moz-txt-link-abbreviated" href="mailto:heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">heispsycho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a> wrote: </pre> <blockquote type="cite"> <pre wrap="">Here is a sample... note it works fine with every browsers except opera on non 200 responses. Php code is included in the pre tag. </pre> </blockquote> <blockquote type="cite"> <pre wrap=""><a class="moz-txt-link-freetext" href="http://titan.clunet.edu/test.php">http://titan.clunet.edu/test.php</a> </pre> </blockquote> </blockquote> <pre wrap=""><!----> </pre> </blockquote> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>