new FormData()" application / x-www-form-urlencoded" [英] new FormData() "application/x-www-form-urlencoded"
问题描述
Couchdb只解析application / x-www-form-urlencoded。是否有设置enctype的FormData()属性?
Couchdb only parse application/x-www-form-urlencoded. Is there a FormData() attribute that set the enctype?
xhr.open('put',document.myForm.action,false)
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
xhr.send(new FormData(document.myForm))
推荐答案
不, XHR2发送方法被指定为始终将FormData对象作为multipart / form-data发送。
No, the XHR2 "send" method is specified to always send FormData objects as multipart/form-data.
正如&符号所示,一种选择是使用 jquery.couch.js 插件内置于Futon中的每个CouchDB实例中。
As ampersand suggests, one option would be to use the jquery.couch.js plugin that's built into every CouchDB instance within Futon.
如果你喜欢更通用的HTTP接口, Fermata 也支持URL编码请求:
If you like a bit more generic HTTP interface, Fermata also has support for URL encoded requests:
fermata.json(document.myForm.action).put({'Content-Type':"application/x-www-form-urlencoded"}, {...form fields...});
另一种选择是将JSON发送到您的更新功能(我假设是'动作' 你的表单的URL而不是。
Another option would be to send JSON to your update function (which I'm assuming is the 'action' URL of your form) instead.
当然,任何这些的诀窍是你必须自己提取表单字段,因为没有简单的DOM - 等级 new FormData(document.myForm)
返回一个Object而不是AFAIK。
Of course, the trick with any of these is that you'll have to extract the form fields yourself, since there's no easy DOM-level equivalent of new FormData(document.myForm)
that returns an Object instead AFAIK.
这篇关于new FormData()" application / x-www-form-urlencoded"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!