12/6/2021

Extjs Download File

42
Active1 year, 5 months ago

The problem is very simple: i have to download a file when i submit a form, it's an ajax call when the form is submitted which lets me build a file with the data taken from the form, server side, and then send it as a link to an alert. The fact is that my boss want the file to be downloaded directly and not through a link in an alert.

I have trying to implement the export functionality in ExtJS 5 using form submit method. And I had look at the following stackoverflow link, it helps but not fully.

In my case i facing an issue after the request response is successful, getting invalid JSON encoding error.Even i tried to change the reader from JSON reader to some other string reader(mentioned in link), but it is quite successful for some reason.

Code:-

Error Message:-

Output response from Java servlet(CSV):-

I think because of this encoding issue,even after the request returns 200 success status; the browser download window is not getting poped up! You help is much appreciated, thanks in advance!

I have modified the code something like below, but still the browser download is not happening event though the response is 200.

Extjs Download File

Modified code with Iframe/Form:-

Note: I'm using Google Chrome browser!

Thanks!

Community
Thirunavukkarasu MuthuswamyThirunavukkarasu Muthuswamy
1201 gold badge4 silver badges15 bronze badges

3 Answers

Extjs 6.5 Gpl Download

export can be achieved with ajax call, creating a Blob out of the response and saving using msSaveBlob. this works in modern browsers ie10 and above

Anusha ManneAnusha Manne

Do you have any headers configuration for the response?

Vladimir Cacic-ArapovicVladimir Cacic-Arapovic

Create a Sencha OnPostDownloader component like this using invisible form and 0 height iframe.

Extjs download file via ajax
Sanjay SinghSanjay Singh

Not the answer you're looking for? Browse other questions tagged javascriptextjsextjs4riaextjs5 or ask your own question.