[Dojo-interest] bind() and POST

Scott J. Miles sjmiles at turbophp.com
Sun May 15 15:10:52 PDT 2005


Thanks for the response.

>> - 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. <<

Well, I would like to send a block of raw data, not some set of name/value
pairs. 

In the code I have now, 'postContent' is unadulterated while 'content' is
processed by argsFromMap.

i.e.

		if(kwArgs["content"]){
			query += dojo.io.argsFromMap(kwArgs.content);
		}

		if(kwArgs["postContent"]){
			query = kwArgs.postContent;
		}

>> http.setRequestHeader('Content-Length', query.length);

AFAIK, the 'content-length' is not necessary, but would it be useful to
include it anyway?
 
Scott

-----Original Message-----
From: dojo-interest-bounces at dojotoolkit.org
[mailto:dojo-interest-bounces at dojotoolkit.org] On Behalf Of David Schontzler
Sent: Sunday, May 15, 2005 2:55 PM
To: dojo-interest at dojotoolkit.org
Subject: Re: [Dojo-interest] bind() and POST

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). 
> 
<snip>

-- 
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
 



More information about the Dojo-interest mailing list