开发者

how to connect couchdb database using javascript

开发者 https://www.devze.com 2023-01-30 01:52 出处:网络
I am new to couchDB and Javascript. I need a simple java script code for connecting CouchDB database and reading a document and display开发者_Go百科ing the content in the browser window.

I am new to couchDB and Javascript. I need a simple java script code for connecting CouchDB database and reading a document and display开发者_Go百科ing the content in the browser window.

Please anyone help me.

Thanks, Nandha.


Using jQuery, you can display your document in <div id="target"></div> like this:

$('#target').load('/database/document-id');

To actually receive the document as a JavaScript object and manipulate it:

$.get('/database/document-id',{},function(doc) {
  // Do something with 'doc' here: 
  alert(doc._id);
},'json');


Don't forget to check out the Javascript examples here: https://github.com/apache/couchdb/tree/master/share/server

0

精彩评论

暂无评论...
验证码 换一张
取 消