[Dojo-interest] dojo.xhrPost() X dojo.io.iframe.send()

Fausto Andrade burnsfumec at gmail.com
Tue Mar 16 10:10:48 EDT 2010


tks guys! this code help me a lot!

On Tue, Mar 16, 2010 at 11:06 AM, Peter Higgins <dante at dojotoolkit.org>wrote:

> Here is the relevant code from dojox/form/FileInputAuto.js
>
>        var _newForm;
>        if(dojo.isIE){
>            // just to reiterate, IE is a steaming pile of code.
>            _newForm = document.createElement('<form
> enctype="multipart/form-data" method="post">');
>            _newForm.encoding = "multipart/form-data";
>
>        }else{
>            // this is how all other sane browsers do it
>            _newForm = document.createElement('form');
>            _newForm.setAttribute("enctype","multipart/form-data");
>        }
>        _newForm.appendChild(this.fileInput);
>        dojo.body().appendChild(_newForm);
>
>        dojo.io.iframe.send({
>            url: this.url,
>            form: _newForm,
>            handleAs: "json",
>            handle: dojo.hitch(this,"_handleSend")
>        });
>
> Hope this helps.
>
> Regards,
> Peter
>
> Mike Wilcox wrote:
> > As Dustin suggested, look at some of the Dojo code that has already
> > done this – dojox FileUploader, FileInput, FileInputAuto, etc.
> >
> > iirc, IE has some funniness and you have to create the form and it's
> > enctype a certain way.
> >
> > Mike Wilcox
> >
> > On Mar 15, 2010, at 9:30 AM, Fausto Andrade wrote:
> >
> >> Hello guys, anyone have more ideas about this problem?
> >>
> >> tks!
> >>
> >> On Fri, Mar 12, 2010 at 3:38 PM, Fausto Andrade <burnsfumec at gmail.com
> >> <mailto:burnsfumec at gmail.com>> wrote:
> >>
> >>     Hmm..  right Dustin.. good information.. you have any idea of
> >>     what kind of trouble my "enctype" attribute form can bring?
> >>
> >>     tks!
> >>
> >>     On Fri, Mar 12, 2010 at 3:19 PM, Dustin Machi
> >>     <dmachi at dojotoolkit.org <mailto:dmachi at dojotoolkit.org>> wrote:
> >>
> >>         I'd take a look at the FileUploader code and see how it works. I
> >>         wouldn't think you could set the headers in xhrArgs for an
> >>         iframe io
> >>         request.
> >>
> >>         Dustin
> >>
> >>         On Mar 12, 2010, at 12:50 PM, Fausto Andrade wrote:
> >>
> >>         > Hello Kit,
> >>         >
> >>         > do you understand the issue?
> >>         >
> >>         > i need to use send() because i have files to be uploaded...
> >>         >
> >>         > tks!
> >>         >
> >>         > On Fri, Mar 12, 2010 at 11:57 AM, Kitson Kelly
> >>         <kitson.kelly at asseverate.co.uk
> >>         <mailto:kitson.kelly at asseverate.co.uk>
> >>         > > wrote:
> >>         > Personally, what I do is use the deferred object returned
> >>         from the
> >>         > new dojo.xhrPost().
> >>         >
> >>         > I would drop the load and error from the args and do
> >>         something like
> >>         > this:
> >>         >
> >>         > var xhrArgs = {...};
> >>         >
> >>         > var deferred = new dojo.xhrPost(xhrArgs);
> >>         >
> >>         > deferred.addCallback(function(data) {
> >>         > ...
> >>         > });
> >>         >
> >>         > deferred.addErrback(function(err) {
> >>         > ...
> >>         > });
> >>         >
> >>         > Personally, this is much cleaner and make the code easier
> >>         for me to
> >>         > read.  Once I found out you could do this, I continued to
> >>         go with it.
> >>         >
> >>         > Regards,
> >>         > Kit
> >>         >
> >>         > On 12 March 2010 13:51, Fausto Andrade
> >>         <burnsfumec at gmail.com <mailto:burnsfumec at gmail.com>> wrote:
> >>         > anyone?
> >>         >
> >>         > On Thu, Mar 11, 2010 at 10:49 AM, Fausto Andrade
> >>         > <burnsfumec at gmail.com <mailto:burnsfumec at gmail.com>> wrote:
> >>         > Hello!
> >>         >
> >>         > I have a form where  i set the enctype to
> >>         "multipart/form-data", and
> >>         > then i´m using dojo.io.iframe.send().
> >>         >
> >>         > In other situations  i just use dojo.xhrPost().
> >>         >
> >>         > My xhrArgs object looks like this:
> >>         >
> >>         > var xhrArgs = {
> >>         >                                         preventCache : true,
> >>         >
> >>         >                                         failOk : true,
> >>         >
> >>         >                                         handleAs: "json",
> >>         >
> >>         >                                         headers: {
> >>         >
> >>         "Content-Type":
> >>         > "application/x-www-form-urlencoded;charset=utf-8"
> >>         >                                         },
> >>         >                                         load: function
> >>         (response,
> >>         > ioArgs) {
> >>         >                                                      //etc...
> >>         >                                         },
> >>         >                                         error:
> >>         function(error,ioArgs){
> >>         >                                                     //etc...
> >>         >                                         }
> >>         >                                   }
> >>         >
> >>         > Once i have xhrArgs defined i decide to call send() or
> >>         xhrPost().
> >>         >
> >>         > As you guys can see, i set the "headers" attribute (for
> charset
> >>         > encoding reasons).
> >>         >
> >>         > Ok, let´s go to the problem: when "enctype" is set at my
> >>         form tag
> >>         > and i use send(), NOTHING is sent at the request. When i
> >>         remove the
> >>         > enctype attribute from the tag
> >>         > then the request object is populated. I make some tests
> >>         like setting
> >>         > the headers attribute of my xhrArgs to
> >>         "multipart/form-data",  or
> >>         > not setting headers at all. The results is the same: when
> >>         enctype is
> >>         > set NOTHING is sent whit send(). So i remove the enctype
> >>         and just
> >>         > set the headers to "multipart/form-data" at the xhrArgs, then
> >>         > request was populated but no file was sent with my request.
> >>         >
> >>         > Tks for any help.
> >>         >
> >>         >
> >>         >
> >>         >
> >>         > _______________________________________________
> >>         > FAQ: http://dojotoolkit.org/support/faq
> >>         > Book: http://docs.dojocampus.org <http://docs.dojocampus.org/
> >
> >>         > Dojo-interest at mail.dojotoolkit.org
> >>         <mailto:Dojo-interest at mail.dojotoolkit.org>
> >>         > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >>         >
> >>         >
> >>         >
> >>         >
> >>         > --
> >>         > Asseverate Limited (Registration No. 6964209) is a limited
> >>         company
> >>         > incorporated in England and Wales with its registered
> >>         office at 149A
> >>         > Bedford Hill, London, SW12 9HF.
> >>         >
> >>         > _______________________________________________
> >>         > FAQ: http://dojotoolkit.org/support/faq
> >>         > Book: http://docs.dojocampus.org <http://docs.dojocampus.org/
> >
> >>         > Dojo-interest at mail.dojotoolkit.org
> >>         <mailto:Dojo-interest at mail.dojotoolkit.org>
> >>         > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >>         >
> >>         >
> >>         > _______________________________________________
> >>         > FAQ: http://dojotoolkit.org/support/faq
> >>         > Book: http://docs.dojocampus.org <http://docs.dojocampus.org/
> >
> >>         > Dojo-interest at mail.dojotoolkit.org
> >>         <mailto:Dojo-interest at mail.dojotoolkit.org>
> >>         > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >>
> >>         _______________________________________________
> >>         FAQ: http://dojotoolkit.org/support/faq
> >>         Book: http://docs.dojocampus.org <http://docs.dojocampus.org/>
> >>         Dojo-interest at mail.dojotoolkit.org
> >>         <mailto:Dojo-interest at mail.dojotoolkit.org>
> >>         http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >>
> >>
> >>
> >> _______________________________________________
> >> FAQ: http://dojotoolkit.org/support/faq
> >> Book: http://docs.dojocampus.org
> >> Dojo-interest at mail.dojotoolkit.org
> >> <mailto:Dojo-interest at mail.dojotoolkit.org>
> >> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > FAQ: http://dojotoolkit.org/support/faq
> > Book: http://docs.dojocampus.org
> > Dojo-interest at mail.dojotoolkit.org
> > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> >
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-interest/attachments/20100316/184d8232/attachment.htm 


More information about the Dojo-interest mailing list