我的本地couchdb实例似乎不支持POST方法.
这是我从chrome dev工具得到的答案
POST http://localhost:5984/epos-couch/_design/epos-couch/_view/ri 415 (Unsupported Media Type)
Run Code Online (Sandbox Code Playgroud)
正在使用的代码是一个简单的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');
}
});
Run Code Online (Sandbox Code Playgroud)
我很确定问题出在我的本地实例中,因为在cloudant.com上运行这样的代码 很好.
所以我的问题是:如何设置我的本地couchdb实例来支持POST方法?
我搜索的interet位(http://wiki.apache.org/couchdb,http://guide.couchdb.org/),但couln't找到答案.
您需要contentType: "application/json"在$.ajax通话中指定,因为CouchDB的某些配置在收到非application/jsonPOST主体时会阻塞.