0

I want to generate xls reports for AJAX search results. Is it possible to pass params for generating Excel document or add params in URL ?

Here is how I generating URL for downloading XLS document:

<%= link_to url_for(request.params.merge({:format => :xls}))  do%>
  <%= image_tag("excel.png")%> <b>Export</b>
 <% end %>

and it is working with standard search, but not with AJAX.

My js code for AJAX search

$('#run_report').submit(function () {  
  $.get(this.action, $(this).serialize(),'script');  
  return false;  
});  

Can someone suggest how to do it ?

MID
  • 1,815
  • 4
  • 29
  • 40

1 Answers1

0

I am not aware of an xls dataType for ajax. The dataTypes I am aware of are xml, html, script, json, jsonp, text. So using ajax with an xls file may require a two step approach.

In my search to complete a task similar to your question I came across the following which may achieve the download you are looking for : Downloading xls file .Hopefully you will also find it useful.

Community
  • 1
  • 1
codepuppy
  • 1,130
  • 2
  • 15
  • 25