[Dojo-interest] bind() and POST

David Schontzler schontz at gmail.com
Sun May 15 14:54:46 PDT 2005


Alright, so I went in there and changed/fixed a few things. Here's
what happened...

- postContent is now an alias for content. There didn't seem to be any
logical reason to have both of these. As it stands, postContent would
just clobber content anyhow.
- added contentType as an argument to the obj passed to bind. It only
applies to POSTs and, if none is specified, uses
"application/x-www-form-urlencoded" as the content type. (Note: Opera
doesn't support this since it doesn't support setRequestHeader()).
- fixed doLoad to better handle sync or async (you probably don't care
about this part so much...)

So you should be able to do your binds like so:

dojo.io.bind({
 url: "foo",
 method: "post",
 content: {someData: "someValue", moreData: "moreValue"},
 // load, error, and/or handle methods...
});

Hope that helps.

-David

On 5/15/05, Scott J. Miles <sjmiles at turbophp.com> wrote:
>  
>  
> 
> I'm building a simple JS <-> PHP protocol to work with dojo.bind (c.f.
> "Marshalling support" thread). 
> 
>   
> 
> At first glance, it seems to be there are basically two ways to send data
> via bind(), as a GET query string or as <form> encoded data. 
> 
>   
> 
> I want to send a custom data packet, but I'm concerned about length
> limitation on GET parameter strings, so I decided to POST a raw data block
> (ASCII). 
> 
>   
> 
> I have two questions: is that decision wrong-headed, and if not, is there an
> established way of accomplishing it? 
> 
>   
> 
> To keep working, I solved it thus: 
> 
>   
> 
> Poking around in BrowserIO.js I saw that I could specify POST for bind()
> with the "method" parameter and store my data block in the "postContent". As
> noted in the code however, there isn't any parameter to control the
> content-type, so I added the following directly to the bind()
> implementation: 
> 
>   
> 
> if(kwArgs["postContent"]){ 
> 
> http.open("POST", url, async); 
> 
> http.setRequestHeader('Content-Length', query.length); 
> 
>             http.setRequestHeader("Content-Type", "text/plain;
> charset=US-ASCII"); 
> 
>             http.send(query); 
> 
> }else 
> 
> if(kwArgs.method.toLowerCase() == "post"){ … 
> 
>   
>  
>  
> 
> Scott 
> 
>   
>  
> 
> --
>  No virus found in this outgoing message.
>  Checked by AVG Anti-Virus.
>  Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 5/13/2005
>  
> _______________________________________________
> Dojo-interest mailing list
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
> 
> 
>


More information about the Dojo-interest mailing list