1

I have some legacy code that uses http://jquery.malsup.com/form/. The legacy code, takes search parameters from a form , makes a DB query and display the results back. (Using Java Servlets)

ajaxForm was used by registering the output of form to go to a particular target (div).

Now we need to add Export functionality. When we create the excel file and set the contentType and Content Disposition like below, still the excel file is not coming as a 'Save As' popu-up, instead it goes to the same 'div' and excel content is splashed on the html division with strange characters.

response.setContentType("application/vnd.ms-excel; charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ "Report" + ".xls");

I would like to know if there's a way to disable the registration of target to that specific div for 'excel output requests and enable it back for regular search requests.

I referred to this link - Better way to temporarily disable ajax submission on ajaxForm plugin , but still clueless. Thanks for any help.

Community
  • 1
  • 1
pkr13
  • 107
  • 2
  • 10
  • 1
    Maybe not an exact duplicate question, but it sounds like what you're asking is how to invoke a "Save As" dialog from JavaScript when downloading a file from the server. This looks very helpful: http://stackoverflow.com/a/9970672/328193 – David Jan 23 '14 at 13:37

1 Answers1

1

The link i gave in the above question helped me to solve this issue. My bad, i should have persisted and tried more with the approach given there. I have updated that question with my findings too. Thanks.

Triggering custom events did the trick. Also instead of using ajaxForm, i used ajaxSubmit.

pkr13
  • 107
  • 2
  • 10