-
29 Aug 2012 7:47 AM #1
Answered: POST form data and get file
Answered: POST form data and get file
I need to send data to the server, who's response is a file, so I cannot handle it with the standard AJAX method.
So far, I can send GET requests by adding an "url" parameter to the button, and, in the controller's button handler, I simply do this:
As you can see, I've created an "Ext.Box" in my view, then I update its content with an iframe. This is working well, but now I need to do the same, but instead of sending a GET request I need to do a POST, because I have to send a lot of text to the server.Code:onGetPDF: function(button){ var win = button.up('window'); lUrl = button.href; Ext.getCmp('pdfBox').update( '<iframe src="' + lUrl + '">' ); }
-
Best Answer Posted by martinrame
Great! I like that idea.
-
29 Aug 2012 10:05 PM #2Ext JS Premium Member
- Join Date
- Jan 2008
- Location
- Germany, Berlin
- Posts
- 123
- Vote Rating
- 7
- Answers
- 18
I usually do a simple POST-submit, generate the file server-side, store it in the file system, send the name of the new generated file as response and on Ext-side I have a callback-function on form.submit which takes the response, extracts the filename and then proceeds with your iframe-solution.
Works like a charm, only drawback is the generation of files in the filesystem so you'll have to clear up once in a while ....
HTH
Florian
-
30 Aug 2012 2:52 AM #3
Thanks Florian, yes I thought about a similar solution, but I don't like to create temp files on server side. Hopefully someone finds a cleaner solution.
-
30 Aug 2012 9:27 PM #4Ext JS Premium Member
- Join Date
- Jan 2008
- Location
- Germany, Berlin
- Posts
- 123
- Vote Rating
- 7
- Answers
- 18
You could store the POST data in a user-session and send the ID back to the user which then in turn embeds the iFrame calling your URL including the ID which then renders the PDF ... so no temporary files will be stored on the server ....
-
31 Aug 2012 5:08 AM #5


Reply With Quote