You can't download files like that via AJAX. What you can do, and what I've done in the past, is use an iframe to push the download to the browser.
In the past I've used AJAX to check the server to see if the downloadable file is ready for download. I do this by creating a unique download token that gets marked as ready right before I push the file back in the iframe. Once my AJAX script finds the token is marked ready I stop the AJAX script and perform my JS code. -Dan On Monday, December 27, 2010, marc -- <[email protected]> wrote: > > Hi, > > I have a page with a print button. When I click that button, a pdf is > generated by CF and sent to the client using cfdocument, mime-type > application/pdf and a header content-disposition so that the pdf is treated > as an atachment. That works fine if I don't use Ajax. But I can't get this to > work using Ajax. > I try to do this using this Jquery: > > function printInvoice(){ > $.ajax({ > url:"/?event=invoice.print", > > data:{invoiceId:$("input[name=invoiceId]").attr("value")}, > > success:function(data){location.href="/?event=invoice.list";}, > async:false, > type:"get" > }); > location.href="/?event=invoice.list"; > return false; > > } > > As you can see, when the pdf is retrieved the onsuccess callback should > refresh the page. This refreshing does work but the pdf is not displayed - I > don't get a window asking me if I want to save or view the attachment I get > when not using Ajax. > > How can I get this to work? > > Marc > > fwiw - I use ModelGlue 3.1 and CF 9.0.1 on Mac OS X. JQuery 1.4.2 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340282 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

