1. #11
    Ext User
    Join Date
    Jul 2008
    Posts
    3
    Vote Rating
    0
    tvald is on a distinguished road

      0  

    Default


    Hi, I just ran in to this bug, so I wanted to follow up on the documentation update.

    Animal - I don't know where in the documentation you planned to insert your changes, but I found the server response details in the API description of Ext.form.Action.Submit, which didn't say anything about response type.

    Thanks!
    -Tony

  2. #12
    Ext JS Premium Member
    Join Date
    Jul 2007
    Posts
    218
    Vote Rating
    2
    ZooKeeper is on a distinguished road

      0  

    Default


    I'm facing a problem with form submit that cause it to fail if I set response content-type to something other then 'text/html'
    Is there any reason for this limitation?

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

      0  

    Default


    Yes.

    For a form upload, it's not an Ajax request, it's a normal browser form submission, and the result is processed by the browser to create a document. So you must tell it that the response is text/html so that it doesn't magle it by wrapping it with <pre></pre>

  4. #14
    Ext JS Premium Member
    Join Date
    Jul 2007
    Posts
    218
    Vote Rating
    2
    ZooKeeper is on a distinguished road

      0  

    Default


    Thanks for clarifying this one.

  5. #15
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    256
    Vote Rating
    1
    brookd is on a distinguished road

      0  

    Default File Upload Not working

    File Upload Not working


    I have been trying this for days, and now I am posting. I have read all the stuff related to file uploads, but I can't figure this out.

    First, this *works* when I do it on our live server, or when I test it on my local server. But when I try to upload from my local test server to my live server it fails. So it must be some cross domain access problem??

    ---

    I have a file upload form, a simple implementation, after I do the upload, I don't get an error, and the file IS uploads, but I don't get any response text.

    ----

    I am breaking on the error (when I try to check a responsetext value), and if I inspect the document I can clearly see my json response in the hidden iframe, everything looks fine:

    Code:
    <iframe id="ext-gen41" class="x-hidden" name="ext-gen41">
     <html>
      <head/>
       <body>{"errmsg":"","msg":"","errdetail":"","data":"csv","success":true}</body>
     </html>
    </iframe>
    Under the Net Tab in firebug, the header shows text/html as is instructed:

    Code:
    Response Headers
    Connection	close
    Date	Sun, 14 Dec 2008 22:34:42 GMT
    Server	Microsoft-IIS/6.0
    Content-Type	text/html; charset=utf-8
    But the response object and responseText/responseXml are empty. I am at a complete loss here. It must be something related to cross site scripting right?

    Anybody have any ideas?

    FYI, our development environment includes a local server to run all of the js code locally, and all ajax requests are made to an external server. We've enabled these permissions in firefox and IE to allow the cross domain scripting for development, but maybe this is something to do with accessing the iframes content. Although I would have thought the iframe that is generated would be accessible to the page..

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

      0  

    Default


    You can debug this all the way through.

    Start your page, switch to Firebug's debug tab, select ext-all-debug.js, and find the following code:

    Code:
        doFormUpload : function(o, ps, url){
    Scroll down a few lines, and you will see the callback function that is set up as a load listener on that iframe which scrapes the result, and builds the fake XHR.

    Code:
            function cb(){
                var r = {  // bogus response object
                    responseText : '',
                    responseXML : null
                };
    
                r.argument = o ? o.argument : null;
    
                try { //
                    var doc;
                    if(Ext.isIE){
                        doc = frame.contentWindow.document;
                    }else {
                        doc = (frame.contentDocument || window.frames[id].document);
                    }
                    if(doc && doc.body){
                        r.responseText = doc.body.innerHTML;
                    }
                    if(doc && doc.XMLDocument){
                        r.responseXML = doc.XMLDocument;
                    }else {
                        r.responseXML = doc;
                    }
                }
                catch(e) {
                    // ignore
                }
    
                Ext.EventManager.removeListener(frame, 'load', cb, this);
    
                this.fireEvent("requestcomplete", this, r, o);
    
                Ext.callback(o.success, o.scope, [r, o]);
                Ext.callback(o.callback, o.scope, [o, true, r]);
    
                setTimeout(function(){Ext.removeNode(frame);}, 100);
            }
    Set a break in there, and you can follow how it processes your response step by step.

  7. #17
    Ext User
    Join Date
    Feb 2009
    Posts
    3
    Vote Rating
    0
    beto.ch is on a distinguished road

      0  

    Default


    then, anyone have a solution for this problem?

    Code:
     
    
    formPanel.getForm().submit({ waitMsg:
    '<spring:message code="msg.guardando"/>', // Wait Message
    success:
    function (form, action) { // When saving data success
    obj = Ext.util.JSON.decode(action.response.responseText); Ext.MessageBox.alert (
    '<spring:message code="msg.info"/>','<spring:message code="msg.exitoguardar"/>'); // clear the form
    formPanel.getForm().reset(); }, failure:
    function (form, action) { // when saving data failed
    obj = Ext.util.JSON.decode(action.response.responseText); Ext.MessageBox.alert (
    '<spring:message code="msg.error"/>','<spring:message code="msg.errorGuardar"/>' + ':' + obj.errorMessage); }
    });
    in firefox the function

    function
    (form, action)

    don't return anything, but with IE works


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

      0  

    Default


    WHy not just past plain code with [ code] tags instead of all kinds of weird <font> and <color> stuff? Unreadable.

    Anyway. Read the docs.

    Content-Type: text/html

  9. #19
    Ext User
    Join Date
    Feb 2009
    Posts
    3
    Vote Rating
    0
    beto.ch is on a distinguished road

      0  

    Default


    sorry about my last post...i'll try to use tag in future post.

    But i don't know where i have to do the change...

    in my page i have a contentType="text/html"

    Code:
    <%@ pagelanguage="java"contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    thank you very much.

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

      0  

    Default


    That is what processes the upload is it?

    WHy use a JSP to process an upload? Surely you would use a servlet?