1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    26
    Vote Rating
    0
    mpriatel is on a distinguished road

      0  

    Default <pre>json</pre> in File upload response (FF only)

    <pre>json</pre> in File upload response (FF only)


    I'm actually not 100% sure if this is an Ext bug or not, but I'm having problems with the following code (essentially handling a File Upload through a Ext.Window):

    Code:
    // ignore ${auto_var} -- it is part of a code generator
    
    var ${auto_var}_form = new Ext.form.FormPanel({
      frame : true,
      defaultType : 'textfield',
      waitMsgTarget : true,
      bodyStyle : 'padding:5px 5px 0',
      labelAlign : 'left',
      buttonAlign: 'right',
      fileUpload : true,
      enctype : 'multipart/form-data',
      items : [
      {
        fieldLabel : 'Attachment',
        inputType : 'file'
      }
    ]
    });
    
    var ${auto_var}_submit = ${auto_var}_form.addButton({
      text:"Submit",
      handler: function()
      {
        ${auto_var}_form.form.submit({
          url:'upload',
          waitMsg : "Uploading...",
          success: function(f,a){
            console.log(a);
          }
      });
      }
    })
    Console reports:
    Code:
    [Break on this error] (<pre>{success:true}</pre>)
    I know for 100% that I am not returning <pre> tags.

    What is happening, I think, is that because the response happens in an IFRAME (because of File Upload, I presume), Firefox is automatically wrapping the response in a DOM, then the IFRAME content is pulled out and eval'ed.

    My Spring controller simply returns:

    Code:
    res.setHeader("Content-type","text/javascript");
    res.getWriter().write("{success:true}");
    return null;
    I've tried application/json, but this just prompts a File/download dialog.

    The only fix I can think of is edit Ext's decode function to handle the <pre> tags:
    Code:
    this.decode = function(json){
       // check if there are <pre> tags and strip them out.
       return eval("(" + json + ')');
    };
    Any suggestions??

  2. #2
    Ext User
    Join Date
    Apr 2007
    Posts
    17
    Vote Rating
    0
    sturdypine is on a distinguished road

      0  

    Default


    you should modify method 'decode' to get rid of tag '<pre> </pre>'.
    and then everything will work well.
    but i gotta another problem, uploadform works fine in FF, but fails in IE6.0.
    IE cannot submit any request to ther server, and throw some js exception.
    could you give me any clue??

  3. #3
    Sencha User McCornic's Avatar
    Join Date
    Oct 2007
    Posts
    27
    Vote Rating
    0
    McCornic is on a distinguished road

      0  

    Question


    Any body know if this bug is going to be solve?
    Because I have the same issue <pre>...</pre>.
    And i think it's not clean to get rid of tag '<pre> </pre>'.
    And it doesn't look work on IE6
    Please the Ext team help us.... ;-)

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Uploads are done using a form submit which loads an iframe.

    It's expecting an HTML document. It gets the "responseText" by extracting the innerHTML of the document. That's what FF puts there. It wraps plain text responses with <pre> tags.

    There was a long discussion about this with several workaruonds posted, but the dev team have not looked at it.

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    Naneau is on a distinguished road

      0  

    Default


    Has any "official" method of getting around this surfaced yet? I too am facing this (rather annoying) problem.

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Washington, DC
    Posts
    190
    Vote Rating
    0
    esoteric is on a distinguished road

      0  

    Default


    I do file uploads and I have never had this problem, it is all in the way you return the JSON formatted response, for whatever reason, the method being used her is wrapping it in <pre></pre> tags. If you don't return it with that then there is no problem. It isn't a bug.

  7. #7
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    Naneau is on a distinguished road

      0  

    Default


    No, it really is a bug, I know for a fact that my returned json is *not* wrapped in any tags (I have checked and double checked). It seems to be the way Firefox handles content sent to the iframe used to do a file form submit. Fiddling with the response headers either triggers a file download box or the bug. Although, come to think of it, I have yet to try sending it as text/plain (which I'd rather not, seeing as how it's not correct)

  8. #8
    Ext User
    Join Date
    Jul 2007
    Location
    Washington, DC
    Posts
    190
    Vote Rating
    0
    esoteric is on a distinguished road

      0  

    Default


    Interesting, well I will take back what I said, though I haven't seen this problem in my setup, I will have to mess around with it and see if I can duplicate, I suppose for now as suggested earlier, just strip the html tags before decoding.

  9. #9
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    Naneau is on a distinguished road

      0  

    Default


    my search skills seem to have deserted me:

    http://extjs.com/forum/showthread.php?t=8129


    had the answer

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Ah, I'd forgotten the conclusion there, and it's very useful. I will update the documentation to make this absolutely plain!

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar