验证和使用jQuery从CouchDB中提取数据 [英] Authenticating and fetching data from couchdb using jQuery
问题描述
我有服务的CherryPy一个Web应用程序。在这个程序,我想从CouchDB的服务器,preferably使用jQuery获取一些数据。我有验证到服务器的麻烦。当使用:
I have a web app served by cherrypy. Within this app, I would like to fetch some data from a couchdb server, preferably using jquery. I am having trouble to authenticate into the server. When using:
$.couch.login({
name: 'usename',
password: 'password',
success: function() {
console.log('Ready!');
}
});
它发送的登录请求CherryPy的服务器,而不是CouchDB的。据这,我可以使用jquery.ajax设置,因此,我已经尝试使用:
It sends the login request to the cherrypy server, not the couchdb. According to this, I can use jquery.ajax settings and therefore I have tried using:
$.couch.login({
url: 'http://127.0.0.1:5984',
name: 'usename',
password: 'password',
success: function() {
console.log('Ready!');
}
});
但它似乎并没有工作。
有任何想法吗?此外,任何人可以点我好教程或以类似的方式开发简单的Web应用程序,即标准的网页(不是couchapp),其中包含jQuery的从沙发上获得的信息。
but it does not seem to work. Any ideas? In addition, can anybody point me to good tutorial or simple web app developed in a similar fashion, i.e. a "standard" web page (not a couchapp), which contains jquery that gets info from couch.
推荐答案
你目前做的是告诉jquery.couch.js登录针对URL。 (它需要张贴到/ _session)
What you are currently doing is telling jquery.couch.js to login against that url. (It needs to POST to /_session)
我相信你需要建立在 $的
。 URL preFIX
属性。沙发
I believe you need to set up the urlPrefix
property on $.couch
.
$.couch.urlPrefix = "http://localhost:5984/"; // run this before anything else with $.couch
这篇关于验证和使用jQuery从CouchDB中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!