[ 6 posts ]

Dimitar Bonev

  • Joined: Mon Aug 22, 2011 2:58 am
  • Posts: 2
  • Offline
  • Profile

YUI 3.4.0 AJAX form upload problem

Post Posted: Tue Apr 17, 2012 2:50 am
+0-
Hello, I am trying to submit a form that has a file input element. Without setting the property 'upload' the form submits successfully. When 'upload' is set to boolean 'true' the form again submits successfully but there is a different behavior between Chrome and Firefox and neither of them is the result I am striving to accomplish. Here is part of the code:

Code:
         console.log('attach submit handler');
         formNode.on('submit', function (event) {
            event.preventDefault();
            event.stopPropagation();
            console.log('submit handler called');
            sendRequest();
         });

         sendRequest = (function initRequest(node, formNode) {
            var url = formNode.getAttribute('action');
            var method = formNode.getAttribute('method') || 'post';
            
            var request = A.io.request(url, {
               method: method,
               dataType: 'text/html',
               autoLoad: false,
               form: {
                  id: formNode,
                  upload: true
               },
               on: {
                  start: function (e) {
                     console.log('request start callback called');
                  },
                  complete: function (e) {
                     console.log('request complete callback called');
                     var responseData = this.get('responseData');
                     console.log('responseData', responseData);
                     var responseText = this.get('responseText');
                     console.log('responseText', responseText);
                  }
               }
            });
            
            var result = function () {
               console.log('sending request');
                  request.start();
            };
            
            return result;
         })(dialogBodyNode, formNode);


In Chrome the response of the submit replaces the document content just as a regular non-ajax submit does. In Chrome console the 'complete' callback log message is missing :
Code:
attach submit handler
submit handler called
sending request
request start callback called


In Firefox the response of the AJAX submit is visible in FireBug Net panel but I haven't found a way to get the result from the javascript response object. FireBug console logs:
Code:
attach submit handler
submit handler called
sending request
request start callback called
request complete callback called
responseData null
responseText undefined


The file input element is not required to be set by the user so I am submitting this form without choosing a file and still I have a hard time when 'upload' property is set. I have been searching for a solution and found several issues and forum threads related to submitting a form with a file input element to upload. I am using AUI framework that wraps YUI version 3.4.0. Thank you in advance!

Marc

YUI Contributor

  • Offline
  • Profile

Re: YUI 3.4.0 AJAX form upload problem

Post Posted: Tue Apr 17, 2012 9:20 am
+0-
I'd like to throw this problem in the hat also: viewtopic.php?f=92&t=9560 I am also experiencing problems with form submissions when upload is set to true

Marc

YUI Contributor

  • Offline
  • Profile
Tags:

Re: YUI 3.4.0 AJAX form upload problem

Post Posted: Mon Apr 23, 2012 7:55 am
+0-
BTW Here is the ticket I created at the time: http://yuilibrary.com/projects/yui3/ticket/2531860

I hope that this issue gets some love from the dev team. It's seems pretty major to me and I can't find a workaround.

Cheers,
Marc

Jane C

  • Username: new2000
  • Joined: Tue Apr 17, 2012 1:07 am
  • Posts: 5
  • Offline
  • Profile
Tags:

Re: YUI 3.4.0 AJAX form upload problem

Post Posted: Mon Apr 23, 2012 8:35 pm
+0-
It looks that YUI3 is really not stable, it's the first function I need to use, io-base, maybe it's a bug, I can not submit the form with 'file' upload via ajax.

It's a break.

Marc

YUI Contributor

  • Offline
  • Profile

Re: YUI 3.4.0 AJAX form upload problem

Post Posted: Tue Apr 24, 2012 6:03 am
+0-
I think YUI 3 is stable, I use it for a large site implementation, although this particular functionality does desperately need some love

Jane C

  • Username: new2000
  • Joined: Tue Apr 17, 2012 1:07 am
  • Posts: 5
  • Offline
  • Profile

Re: YUI 3.4.0 AJAX form upload problem

Post Posted: Tue Apr 24, 2012 10:38 am
+0-
are there any solutions to submit form with file upload via Ajax? Thanks.
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum