Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: ExtJS 6.5 Multipart Fileupload Form Submit always executes SUCCESS=TRUE

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Oct 2007
    Posts
    52

    Default ExtJS 6.5 Multipart Fileupload Form Submit always executes SUCCESS=TRUE

    Hi

    I have a form that sends text and file to the server. Server returns TRUE or FALSE depends on the checking.
    I forced an error on the server to check if my javascript code can handle the {success:false} response properly.
    Weirdly it does not but always executes the TRUE code.
    Screenshot below are the response from server and the console.log data from the SUCCESS code.

    Form Submit Form Code Below:

    PHP Code:

    if( form.validate() ){
        
    showLoadMaskwindow );
        
    form.submit({

            
    success: function(formaction) {
                
    console.logaction );

                
    hideLoadMask(window);
                if ( 
    action.success === true ) {
                    
    console.log("1----");
                    return;
                    
    window.destroy();
                } else {
                    
    console.log("2----");
                    
    Ext.Msg.show({
                        
    title'Error!',
                        
    messageaction.reason,
                        
    width400,
                        
    buttons: [{
                            
    text'Ok',
                            
    style:'margin-right:10px;',
                            
    handler: function() {
                                
    Ext.Msg.hide();
                            }
                        }]
                    });

                }


            },
            
    failure: function(formresponse) {
                
    console.logresponse );
                
    hideLoadMask(window);
                if ( 
    response.success === false ) {

                    
    Ext.Msg.show({
                        
    title'Error!',
                        
    messageresponse.reason,
                        
    width400,
                        
    buttons: [{
                            
    text'Ok',
                            
    style:'margin-right:10px;',
                            
    handler: function() {
                                
    Ext.Msg.hide();
                            }
                        }]
                    });

                }


            }

        });


    01.jpg02.jpg

    Thanks

  2. #2
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    255

    Default

    Your server returned some html tags around your JSON text?

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Quote Originally Posted by richardvd View Post
    Your server returned some html tags around your JSON text?
    The response will be HTML for file uploads and therefore there is code to get the actual JSON. This JSON can be within a <pre>, <textarea> or the <body>. Here is a fiddle and a commented override (uncomment to get the debugger hit) to hook into the method that finds the response:



    This is also in the core so modern also just has this ability:

    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #4
    Sencha User
    Join Date
    Oct 2007
    Posts
    52

    Default

    @richardvd,

    The html tags is there for testing cuz I have experience with Extjs 4 and it requires to have the html tags to be part of the response. The screenshot I posted was with tags. I also tested it without tags, same behavior.

    @mitchellsimoens

    Is this working as intended? or do I to change something?

    thanks!

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    My fiddles are working as intended with the response within the html tags
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #6
    Sencha User
    Join Date
    Oct 2007
    Posts
    52

    Default

    hi mitchellsimoens ,

    I still cant get it to work.. this is my code below....

    PHP Code:
    function addStock() {
        var 
    window undefined;
        
        var 
    form Ext.create('Ext.form.Panel', {

            
    borderfalse,
            
    url'/add',
            
    method'POST',
            
    scrollablefalse,

            
    autoSizetrue,
            
    bbar: {
                
                
    items: [{
                    
    text'<b>Submit</b>',
                    
    id'submitId',
                    
    handler: function() {
                        if( 
    form.validate() ){
                            
                            
    form.submit({
                                
    params: { 'token'"test Token" },
                                
    success: function(formaction) {
                                    
                                    if ( 
    action.response !== undefined && action.response === true ) {                                
                                        
    console.log("1----");

                                        
    window.destroy();
                                    } else {
                                        
    console.log("2----");
                                        
    Ext.Msg.show({
                                            
    title'Error!',
                                            
    messageaction.reason,
                                            
    width400,
                                            
    buttons: [{
                                                
    text'Ok',
                                                
    style:'margin-right:10px;',
                                                
    handler: function() {
                                                    
    Ext.Msg.hide();
                                                }
                                            }]
                                        });

                                    }


                                },
                                
    failure: function(formresponse) {
                                    
                                    
                                    if ( 
    response.success === false ) {

                                        
    Ext.Msg.show({
                                            
    title'Error!',
                                            
    messageresponse.reason,
                                            
    width400,
                                            
    buttons: [{
                                                
    text'Ok',
                                                
    style:'margin-right:10px;',
                                                
    handler: function() {
                                                    
    Ext.Msg.hide();
                                                }
                                            }]
                                        });

                                    }


                                }

                            });
                        }
                    }
                }]
            },
            
    items: [{
                
    padding20,

                
    defaults: {
                    
    xtype'textfield'
                
    },

                
    items: [{
                        
    xtype'numberfield',
                        
    label'<b>Quantity</b>',
                        
    name'qty',                    
                        
    margin'0 5 0 0',
                        
    allowBlankfalse
                    
    }, {
                        
    xtype'filefield',
                        
    label'Item Photo',
                        
    name'pic',
                        
    flex1

                    
    }]
            }]


        });

        
        
    window Ext.create( {
            
    xtype'dialog',
            
    closabletrue,
            
    draggablefalse,
            
    iconCls'x-fa fa-plus',
            
    padding10,
            
    modaltrue,
            
    resizablefalse,
            
    layout'fit',
            
    itemsform,
            
    width500,
            
    height550,
            
    title"New"
        
    });

        
    window.show();




  7. #7
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    What debugging have you done? See the override to hook into the function that handles the response parsing? Use that to debug some.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  8. #8
    Sencha User
    Join Date
    Oct 2007
    Posts
    52

    Default

    @mitchellsimoens

    Here's the debug logs...
    001.jpg
    002.jpg
    003.jpg

  9. #9
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    255

    Default

    You could step through the framework code with your Javascript debugger to find out exactly why and where it takes the wrong code path as you say it does. That will probably give you the clue you are looking for.

    In his fiddles he supplied an override that you have uncomment to enable. You will then have a breakpoint to where the interesting parts are. You can also use that override in your code to do the same.

    But you may want to play with it first in the fiddles since those are already working as intended.

    Code:
    Ext.define(null,
    {    override: 'Ext.data.request.Form',
    
    
        // if you wanna step thru the code that works with the html response
        // here is the method that handles the response
        onComplete: function () {
            debugger;
    
    
            this.callParent(arguments)
        }
    })

  10. #10
    Sencha User
    Join Date
    Oct 2007
    Posts
    52

    Default

    Changed extjs source code to debug.

    Found out that my logging gets executed before the code that was provided by mitchellsimoens

    Image attached

    111.jpg

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 30 Nov 2018, 11:12 AM
  2. Replies: 2
    Last Post: 14 Oct 2013, 11:24 PM
  3. Extjs form fileUpload : true
    By liumingwei2009 in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Jan 2011, 12:55 AM
  4. fileUpload: true causes Form not to submit
    By mebsonvaldezz in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 18 Feb 2009, 4:47 AM
  5. [Solved] FileUpload Form, always success after submit
    By zeroc in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 19 Jul 2007, 1:51 AM

Posting Permissions

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