Downloading CSV via AJAX

ajax, lowpro, prototypejs

Solution

This is a known limitation of Ajax requests, you will need to use JS like:

window.location='download-csv.rb';

Instead of using an Ajax request. Another way is to change the location of a hidden Iframe, but this has it's own pro's/con's.

You will never get an Ajax request to display the 'file save' dialog, no matter what HTTP headers you send.

Problem

Can you use AJAX to download a generated csv file from a web application? If so does anyone have any kind of reference that I could be pointed towards? EDIT: Sorry I should have mentioned I am using Prototype's Ajax.Request and I looked in firebug's response tool and the generated CSV is the response, I just need to get it to pop up with the save file option after has been generated by the Ajax.Request

Original source