after reading that, i think the argument is just silly.  at least 90%
of the forms i'm working on are going to just use querystrings to send
their data, and basically do something very similar just setting a
form method to 'post' in html.  I'm sure someone wants to do something
fancier, but the code below isn't
called FancyPostXMLHttpRequest.  Someone else can write that.  So here
is some untested code:

    doSimplePostXMLHttpRequest: function (url/*, ...*/) {
        var self = MochiKit.Async;
        var req = self.getXMLHttpRequest();
        if (arguments.length > 1) {
                var m = MochiKit.Base;
                var qs = m.queryString.apply(null, m.extend(null, arguments, 
1));
        }
        req.open("POST", url, true);
        //taken from prototype, note that we can't use a hash map here, as
        //we can't have hyphen in the property name
            var requestHeaders =
                        ['X-Requested-With', 'XMLHttpRequest',
                         'X-Prototype-Version', Prototype.Version,
                         'Accept', 'text/javascript, text/html, 
application/xml, text/xml, */*',
                         'Content-type', 'application/x-www-form-urlencoded'];
                /* Force "Connection: close" for Mozilla browsers to work around
                 * a bug where XMLHttpReqeuest sends an incorrect Content-length
                 * header. See Mozilla Bugzilla #246651.
                 */
                if (req.overrideMimeType)
                        requestHeaders.push('Connection', 'close');
                for (var i = 0; i < requestHeaders.length; i += 2)
                        req.setRequestHeader(requestHeaders[i], 
requestHeaders[i+1]);
                
                return self.sendXMLHttpRequest(req)

    },

I don't see a point of asking, how many ways can the developer scratch
his testicles by doing the macarena, so I wrote something i can use,
and test as soon as I figure out why firefox want's to play nice with
something else.  If anyone has a ready test available, let me know it
it works :)

Cheers,
Yaakov
On 7/4/06, Bob Ippolito <[EMAIL PROTECTED]> wrote:
>
> On Jul 4, 2006, at 6:46 AM, Yaakov Nemoy wrote:
>
> > I'm looking through the docs, and I'm not seeing much sophistication
> > to manipulating the actual request.  I'm working on an app using lots
> > of forms, so using POST is pretty critical.  Short of touching the
> > XMLHttpRequests myself (ie, throwing a bit of code ripped off another
> > framework)  is there an official way to set this in Mochikit?
>
> No, there is not a built-in function for doing POST.
>
> http://groups.google.com/group/mochikit/search?group=mochikit&q=post
>
> -bob
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to