Q:

IE won't download file generated with rails

I have created 2 buttons that allow a user to download a HTML table as TXT or Excel. The appropriate files are generated by my Rails app. Everything works fine except for IE. I tested IE11 on Win7.
Live example (See buttons at bottom): http://en.mycoursewalk.com/course_walk/distance_table/3575
HTML Code:
<a href="#" id="Export_Excel" title="Export to Excel" class="ui-btn ui-shadow ui-corner-all"><i class="fa fa-file-excel-o fa-lg"></i> Export to Excel</a>

<script>
    var cw_id = <%= @coursewalk.id %>;
    $(document).on("pageshow",function(event) {
        $("#Export_Excel").click(function(event) {
            export_table('xml');
        });
    });
    function export_table(export_format) {
        var table = $('#distance_table').tableToJSON();
        window.open('/application/export_table/' + cw_id + '.' + export_format + '?table_type=distance_table&export_format=' + export_format + "&_json=" + encodeURIComponent(JSON.stringify(table)), "_self");
    }
</script>

Controller:
  def export_table

     # Code here to create appropriate text or Excel file. Removed for clarity
     formatted_data = ''
     formatted_data << "test" + "\t" + "test2" + "\n"     

     i = Iconv.new('UTF-8','iso-8859-1')
     formatted_data_utf8 = i.iconv(formatted_data)

    send_data formatted_data_utf8, :filename => "test.txt", :type => "text/csv;charset=UTF-8", :disposition => "attachment"

  end

In the IE Developer Tools and Console, IE shows "Navigation Occurred" and a complaint about DOCTYPE when you click on the Export buttons. Clicking on the DOCTYPE warning will actually load the TXT or Excel file into the console.
How can I fix this?

A:

I fixed this issue by using rails templates instead as described in this Rail Cast:
http://railscasts.com/episodes/362-exporting-csv-and-excel?view=asciicast

