postJson

1 view
Skip to first unread message

michelts

unread,
Dec 6, 2006, 11:37:59 AM12/6/06
to MochiKit
Hi guys!

I already use mochikit at some webware (python) projects, now I'm
learning turbogears and I see a code to post json to another page, a
function called postJSON:

var postJSON = function(url, postVars) {
var req = getXMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var data = queryString(postVars);
var d = sendXMLHttpRequest(req, data);
return d.addCallback(evalJSONRequest);
}

What about including this function in mochikit?

Thanks!

--
Michel Thadeu Sabchuk
Curitiba - Brasil

Jorge Godoy

unread,
Dec 6, 2006, 11:54:21 AM12/6/06
to michelts, MochiKit
michelts <mich...@gmail.com> writes:

> What about including this function in mochikit?

Check the archives and you'll see a lot of discussion about that. Specially
the explanations on why there isn't any standard function at the library.

--
Jorge Godoy <jgo...@gmail.com>

Bob Ippolito

unread,
Dec 6, 2006, 2:42:33 PM12/6/06
to Jorge Godoy, michelts, MochiKit
On 12/7/06, Jorge Godoy <jgo...@gmail.com> wrote:
>
> michelts <mich...@gmail.com> writes:
>
> > What about including this function in mochikit?
>
> Check the archives and you'll see a lot of discussion about that. Specially
> the explanations on why there isn't any standard function at the library.

First of all, postJSON is a very bad name for a function that posts
URL encoded variables.. but second, the trunk has a doXHR function
that lets you do all of that stuff (except the evalJSONRequest) in one
function call. It's still a lot of typing, but for whatever reason
people feel more comfortable with one long function call instead of
three equivalent lines, so it's available.

-bob

Reply all
Reply to author
Forward
0 new messages