3

我的本地 couchdb 实例似乎不支持 POST 方法。

这是我从 chrome 开发工具中得到的答案

POST http://localhost:5984/epos-couch/_design/epos-couch/_view/ri 415 (Unsupported Media Type)

使用的代码是一个简单的 ajax 请求,设置了 post 方法:

$.ajax({ 
                    async: true, 
                    url: ajaxURL,
                    type:"POST",
                    data:.....,
                    dataType: 'json',
                    timeout:5000,
                    success:function(response){

                        riResponseList=response.rows;
                        },
                    error:function(){
                        alert('fetching error');
                        }
                    });

我很确定问题出在我的本地实例中,因为在cloudant.com上运行这样的代码 一切正常。

所以我的问题是:如何设置我的本地 couchdb 实例以支持 POST 方法?

我在互联网上搜索了一下(http://wiki.apache.org/couchdb, http://guide.couchdb.org/),但找不到答案。

4

1 回答 1

6

您需要contentType: "application/json"$.ajax调用中指定,因为 CouchDB 的某些配置在收到非application/jsonPOST 正文时会阻塞。

于 2012-06-08T09:01:32.257 回答