I have a page containing documents for download and also some dynamic content. If the user clicks on a link that starts an ajax request and then clicks on a document to download before the ajax request returns, then the browser stops listening for the ajax reply and does not process it. I want the user to be able to download documents without interfering with the ajax on the page. this is how the Ajax request is made : new Ajax.Request(url, { parameters : parameters, onSuccess : this.onSuccess.bind(this) }); If a document link is clicked the onSuccess callback is never clicked The only way I could figure out was using ''onclick=window.open(link)'' on my links. This works, the document is downloaded and the ajax request is not affected. However there is the risk of the document being blocked by popup blockers. Is there a better way of handling this? thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 13 Mar 2008, at 09:56, yiannis wrote:> The only way I could figure out was using ''onclick=window.open(link)'' > on my links. This works, the document is downloaded and the ajax > request is not affected. However there is the risk of the document > being blocked by popup blockers. > > Is there a better way of handling this?A decent popup blocker will not block popups initiated by the user (so onclick popups should always work), that''s how Safari and Firefox work at least. The problem you''re facing has to do with downloads being perceived as navigating to a new page, so you are correct they will probaby break all ongoing ajax requests. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 13 Mar 2008, at 09:56, yiannis wrote:> The only way I could figure out was using ''onclick=window.open(link)'' > on my links. This works, the document is downloaded and the ajax > request is not affected. However there is the risk of the document > being blocked by popup blockers. > > Is there a better way of handling this?Well, there is a way actually to avoid the window of popping up. Add a hidden iframe to your page (1x1px) and do window.open(''yoururl'', ''iframename''), this will make the download open in the iframe. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---