So I have ExtJS application in which a certain open in Combo leads to Download of file (read: Export to PDF). Now currently we do that using window.open
in which we hit a specific URL which is RESTful in nature and something similar to.
window.open('https://example.com/myapp/api/module/someId/exportPDF.pdf?clientId=bizzare123¶m1=someValue');
This opens up new Tab and I get the file to download. Now this is theoretically a GET request (though it doesn't appear in Chrome DevTools' Network tab), and I want to pass some JSON data as request body (data is large so I can't fit it in request params).
Can this be done by calling same URL using Ext.Ajax.request
and passing jsonData
? (I believe then I'll have to handle file coming in the response within success
callback.
Thanks!
P.S. I'm on ExtJS 4.0
Update
Earlier we had only GET request to download the file but to support new feature, we had to customize download by sending POST request first, and API then sent file directly in response to POST request.
But as rixo mentioned in comments that async download of file might not be possible directly, I had to change API such that it sends file URL instead, in POST request, and then I can hit that URL and initiate file download. And given that it's huge enterprise webapp impacting millions of users mostly using IE, I wanted to avoid using modern APIs (which are obviously tempting but not supported on IE, like always).