How to download a file using Ext JS library?

10,022

Solution 1

Sometimes you can use original javascript:

document.location = "/getfile?abc=123";

Solution 2

You might find this thread or this post useful. Basically don't use AJAX here, use a <form> to submit your request

Share:
10,022
aQ123
Author by

aQ123

Updated on June 04, 2022

Comments

  • aQ123
    aQ123 almost 2 years

    I'm a newby in Ext JS and I need to make a restful call that returns a file to the browser. How should I do this?

    This is what I have so far, the call is return but I can't get the file downloaded to the browser.

    Ext.onReady(function () {
    
    form = Ext.Ajax.request({
        url: 'http://localhost:8080/getfile',
        success: function(x){
                     return x; 
                     },
        failure: function () { console.log('failure');},
        params: {'someparams': Ext.encode ({'abc': {'hello': '123'}})
                }
        });
    });