BrowserCouch, help with basic example
I'm trying to get a basic example of BrowserCouch working... the one shown开发者_如何学编程 here: http://hg.toolness.com/browser-couch/raw-file/blog-post/tutorial.html
My code:
<script type="text/javascript" src="browser-couch.js"></script>
<script type="text/javascript">
BrowserCouch.get('blog-posts',
function onRetrieveCb(db) {
blogDb = db; /* Save the DB for later. */
});
</script>
I get this error in the Chrome and FF console:
BrowserCouch is not defined
I've double checked and the browser-couch.js file is correctly src'd.
How can I get this to work?
Looks like you're using code from the blog post but using a newer version of the JavaScript and the newer one has a different API. From the github page:
var database = BrowserCouch('foo');
database.onload(function(){
database.get('bar', function(d){console.log(d)});
});
But the older version wanted what you're doing:
BrowserCouch.get('blog-posts',
function onRetrieveCb(db) {
blogDb = db; /* Save the DB for later. */
}
);
So I think you need to match your API usage to the library version.
精彩评论