Couchdb only parse application/x-www-form-urlencoded. Is there a FormData() attribute that set the enctype?
xhr.open(\'put\',document.myForm.action,false)
xh
Some time ago I wrote the following function. It collects form values and encodes them url encoded, so they can be sent with content type application/x-www-form-urlencoded:
function getURLencodedForm(form)
{
var urlEncode = function(data, rfc3986)
{
if (typeof rfc3986 === 'undefined') {
rfc3986 = true;
}
// Encode value
data = encodeURIComponent(data);
data = data.replace(/%20/g, '+');
// RFC 3986 compatibility
if (rfc3986)
{
data = data.replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
return data;
};
if (typeof form === 'string') {
form = document.getElementById(form);
}
var url = [];
for (var i=0; i < form.elements.length; ++i)
{
if (form.elements[i].name != '')
{
url.push(urlEncode(form.elements[i].name) + '=' + urlEncode(form.elements[i].value));
}
}
return url.join('&');
}
// Example (you can test & execute this here on this page on stackoverflow)
var url = getURLencodedForm('post-form');
alert(url);