1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default 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:

    Code:
    onGetPDF: function(button){
            var win = button.up('window');
            lUrl = button.href;
            Ext.getCmp('pdfBox').update( '<iframe src="' + lUrl + '">' );
    }
    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.

  2. Great! I like that idea.

  3. #2
    Ext JS Premium Member
    Join Date
    Jan 2008
    Location
    Germany, Berlin
    Posts
    135
    Answers
    21
    Vote Rating
    11
    fschaeffer will become famous soon enough

      0  

    Default


    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

  4. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    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.

  5. #4
    Ext JS Premium Member
    Join Date
    Jan 2008
    Location
    Germany, Berlin
    Posts
    135
    Answers
    21
    Vote Rating
    11
    fschaeffer will become famous soon enough

      0  

    Default


    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 ....

  6. #5
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    Great! I like that idea.

Thread Participants: 1

Tags for this Thread