Hi List,
On 7/5/06, Yaakov Nemoy <[EMAIL PROTECTED]> wrote:
> fancier, but the code below isn't
> called FancyPostXMLHttpRequest. Someone else can write that. So here
> is some untested code:
>
> 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,
So here is the code, working in JDeveloper 1013 and works in Firefox and IE.
To use it, it's exactly the same as Async.doSimpleXMLHttpRequest(),
and to integrate it into your MochiKit setup, just add it right after
the same method. Without further ado:
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, pretty much verbatim
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest',
'X-MochiKit-Version', MochiKit.Async.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, qs);
},
If it get's integrated into the next release, let me know :).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---