Results 1 to 6 of 6

Thread: Form submit works in Chrome/FF but not IE11

  1. #1
    Sencha User
    Join Date
    Feb 2016
    Posts
    4

    Default Form submit works in Chrome/FF but not IE11

    Hello,

    I am uploading an attachment file to a server and am displaying these attachments as font icons in a data view below the fileuploadfield buttons. The entire process works perfect using Chrome and FireFox, but not in IE...

    In IE, the form gets submitted and this can be verified on the server side. The server gives it an id number, trims out the path and leaves the file name. On success, my code gets the action.result and adds a new attachment to the store. As I said, this is fine in Chrome and FF, but in IE it fails and the form and action arguments are undefined. The strange thing is I get a dialog box from IE asking me if I want to save or open the JSON response, and the response is just as it should be.

    Ive searched and found people with similar issues, but their solutions have not worked, so any help would be appreciated greatly.

    Heres my code:
    Code:
       
    uploadValidAttachment: function(btn, value){        
           var me = this;
           var form = btn.up('form').getForm();
            var submitUrl = this.getViewModel().get('baseUrl') + '/uploadFiles';
    
            if(form.isValid()){
                Ext.toast('valid');
                debugger;
                form.submit({
                url        : submitUrl,
                headers : {'Content-Type':'multipart/form-data'}, 
                waitMsg    : 'Uploading your document...',
                method    : 'POST',
                success    : function(form, action){
                    debugger;
                    Ext.toast('upload complete');    
                    var response = action.result, docModel =  me.getViewModel().get('doc');
                    var attachment = new RA.model.Attachment({
                        id                :  response.data.fileContent.contentId,
                        name            :  response.data.fileContent.fileName,
                        mimeType        :  response.data.fileContent.mimeType,
                        attachmentType    :  response.data.fileContent.contentType,
                    });
                    me.getViewModel().get('doc').addAttachment(attachment);
                    Ext.toast('adding attachment to store');
                },
                
                failure    :  function(form, action){
                    debugger;
                    var response = action.result;
                    Ext.MessageBox.alert("Error", Ext.encode(this.response.responseText).message);
                },
            });
            }
        },

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    It sounds as though the content type is not being set correctly in the header of the response. Are you using 'application/json'?

  3. #3
    Sencha User
    Join Date
    Feb 2016
    Posts
    4

    Default

    Hi Gary,

    Yes, the response contentType is application/json.

  4. #4
    Sencha User
    Join Date
    Feb 2016
    Posts
    1

    Default

    Hello,

    we have the same issue when uploading an image in IE (Chrome is fine). Instead of an responsebody the browser ask if we wont to download or open a json file.

    Content of the file is the expected response

    {"success":true,"content":["contentpath"]}

    Using Ext 6.5.2 IE 11.1155.15063.0


    Is there a solutin for this issue?

  5. #5
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    Use content-type text/html for the response from the server, and wrap your JSON response in HTML tags:
    Code:
    <html><body>
    {
        "success":true,
        "message":"Upload complete!",
        "content":["contentpath"]
    }
    </body></html>
    Fiddle:

  6. #6

    Default

    Hi,
    I also faced the the same issue with IE.
    In this case i used Ajax instead of form.submit().
    Find the below code.
    May be it will help you.

    var file = s.fileInputEl.dom.files[0],
    data = new FormData();
    data.append('file', file);
    Ext.Ajax.request({
    url: '/upload/files',
    rawData: data,
    headers: {'Content-Type':null}, //to use content type of FormData
    success: function(response){

    }
    });

    in the above code s means file filed.


    Thanks


Similar Threads

  1. Sencha Touch 1.1.1 works on IE11 mobile but not on webview
    By darkhorni in forum Sencha Touch 1.x: Q&A
    Replies: 0
    Last Post: 22 Jun 2015, 12:25 AM
  2. Replies: 4
    Last Post: 20 Jan 2014, 11:49 AM
  3. Auto save email id is not working while form submit in Chrome
    By justusvm in forum Community Discussion
    Replies: 3
    Last Post: 27 Mar 2012, 4:19 AM
  4. Replies: 0
    Last Post: 14 Dec 2010, 12:05 PM
  5. extjs only works in Chrome?
    By BP64531 in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 31 Aug 2009, 9:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •