I''m experiencing some behavior I find very strange when using prototype''s Ajax.Request (happens in both 1.6.0RC1 and 1.5.1.1). When using ''post'', about 90% of the time no data is returned in transport.responseText. (Making the same request over and over with identical data) When using ''get'' it fails about 10% of the time (again, identical data). When I hit the target page in a browser window I never get an error. If I hit a different target page I get the same error rates. When I roll my own ajax code I get zero errors. Help? function sendAjax(strID) { new Ajax.Request(''ajaxPage1.cfm'', { method: ''post'', parameters: ''id=''+strID, onSuccess: function(o){HandleResponse(o,strID);}, onException: handleException }); } Until I added the exception handler I was completely lost as the errors were getting caught and it failed silently. The target page returns a JSON string but that shouldn''t matter since if i change the target page to home.cfm it still returns an empty responseText most of the time. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Oct-23 13:41 UTC
Re: Prototype Ajax.Request problem: no data in responseText
On 23/10/2007, chloraphil <chloraphil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m experiencing some behavior I find very strange when using > prototype''s Ajax.Request (happens in both 1.6.0RC1 and 1.5.1.1). When > using ''post'', about 90% of the time no data is returned in > transport.responseText. (Making the same request over and over with > identical data) When using ''get'' it fails about 10% of the time > (again, identical data). When I hit the target page in a browser > window I never get an error. If I hit a different target page I get > the same error rates. When I roll my own ajax code I get zero > errors. Help? > > function sendAjax(strID) { > new Ajax.Request(''ajaxPage1.cfm'', > { > method: ''post'', > parameters: ''id=''+strID, > onSuccess: function(o){HandleResponse(o,strID);}, > onException: handleException > }); > } > > Until I added the exception handler I was completely lost as the > errors were getting caught and it failed silently. The target page > returns a JSON string but that shouldn''t matter since if i change the > target page to home.cfm it still returns an empty responseText most of > the time.I have found that at any stage a proxy can bugger things up. Not sure why. My solution is to add a timestamp to every ajax request using the following auto responder ... document.observe(''dom:loaded'', function() { Ajax.Responders.register ({ onCreate: function(o_Requester) { // Timestamp each AJAX action. var o_Date = new Date(); o_Requester.url o_Requester.url + (o_Requester.url.indexOf(''?'') == -1 ? ''?'' : ''&'') + ''Stamp='' + o_Date.getTime(); } }); }); So, every request now has a new GET parameter. This means every request is unique and SHOULD void all caching by proxies. It is working for me. YMMV. Regards, Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chloraphil
2007-Oct-23 15:20 UTC
Re: Prototype Ajax.Request problem: no data in responseText
Hi Richard, Thanks for the reply. I don''t believe the issue with caching you''re talking about is what''s causing my problem. For one, i''m using ''post'' which as I understand it will not be cached. Second, i''m including a random number in my parameter list in my real code, I just removed it for simplicity. For good measure I added that random parameter to the actual url and the problem persists. Any other ideas? Just for kicks I ran my hand-coded ajax request next to the prototype Ajax.Request and they both worked, but when I only run the Ajax.Request it bombs. Weird. I''ve checked my server logs and it''s not recording any errors that I can see. Thanks, chloraphil --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chloraphil
2007-Oct-23 17:33 UTC
Re: Prototype Ajax.Request problem: no data in responseText
I''ve made an interesting discovery... if i provide no parameters via the Options object then the call succeeds - with an error message from the server, of course, but still. This happens whether I remove "parameters: ''id=''+strID, " , or set its value to an empty string. Weird! If I provide my parameters in the url then it works, but I really want to know what the hey-ya is going on. On Oct 23, 11:20 am, chloraphil <chlorap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Richard, > > Thanks for the reply. > > I don''t believe the issue with caching you''re talking about is what''s > causing my problem. For one, i''m using ''post'' which as I understand > it will not be cached. Second, i''m including a random number in my > parameter list in my real code, I just removed it for simplicity. For > good measure I added that random parameter to the actual url and the > problem persists. > > Any other ideas? Just for kicks I ran my hand-coded ajax request next > to the prototype Ajax.Request and they both worked, but when I only > run the Ajax.Request it bombs. Weird. > > I''ve checked my server logs and it''s not recording any errors that I > can see. > > Thanks, > chloraphil--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chloraphil
2007-Oct-23 19:34 UTC
Re: Prototype Ajax.Request problem: no data in responseText
also, it works in IE, but not Firefox. any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Oct-24 09:02 UTC
Re: Prototype Ajax.Request problem: no data in responseText
On 23/10/2007, chloraphil <chloraphil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > also, it works in IE, but not Firefox. any ideas?Can you try ... parameters: {id : strID}, This is how I set parameters to the POST (I amend the action for the GET to include my timestamp). -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chloraphil
2007-Oct-24 16:58 UTC
Re: Prototype Ajax.Request problem: no data in responseText
Yep, I tried that as I saw that style in the docs but the problem remains.... I also tried using postBody but no dice. On Oct 24, 5:02 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23/10/2007, chloraphil <chlorap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > also, it works in IE, but not Firefox. any ideas? > > Can you try ... > > parameters: {id : strID}, > > This is how I set parameters to the POST (I amend the action for the > GET to include my timestamp). > > -- > ----- > Richard Quadling > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!"--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chloraphil
2007-Oct-25 13:49 UTC
Re: Prototype Ajax.Request problem: no data in responseText
OK, I found the problem and it''s my fault not prototype''s or whatever. The ajax call is being kicked off by a popup window and it updates a row on the main page. The problem is that the popup page was refreshing before the ajax call was complete, somehow causing the response to be empty. To fix it I put the function call inside a setTimeout. Thanks for your help, Richard. -chloraphil On Oct 24, 12:58 pm, chloraphil <chlorap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yep, I tried that as I saw that style in the docs but the problem > remains.... I also tried using postBody but no dice. > > On Oct 24, 5:02 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > On 23/10/2007, chloraphil <chlorap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > also, it works in IE, but not Firefox. any ideas? > > > Can you try ... > > > parameters: {id : strID}, > > > This is how I set parameters to the POST (I amend the action for the > > GET to include my timestamp). > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!"--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---