Alguem pode me dar um HELP com javascript e couchDB?

7 views
Skip to first unread message

SANTIAGO, Rhuan Victor

unread,
Dec 15, 2009, 12:26:31 PM12/15/09
to CouchDB-BR
Eu queria que o resultado da minha requisição fosse escrito na tela.

<html>
<head>
</head>
<body>
<script type="text/javascript">

var req = new XMLHttpRequest();

req.open("GET", "http://192.168.0.105:5984/_all_dbs");

req.send("");

document.write(req.responseText);

</script>
</body>
</html>

Por que não funciona? e por que se eu colocar
req.responseText.asdadasda ele retorna undefined?

J. Chris Anderson

unread,
Dec 16, 2009, 12:52:50 AM12/16/09
to CouchDB-BR


On Dec 15, 9:26 am, "SANTIAGO, Rhuan Victor"
<rhuanvcsanti...@gmail.com> wrote:
> Eu queria que o resultado da minha requisição fosse escrito na tela.
>

This may be of help:

http://maraksquires.com/articles/2009/10/22/jquery-couch-js-cheatsheet/

If you want a synchronous call, you can try:

var req = new XMLHttpRequest();
req.open("GET", "/_all_dbs", false);
req.send("");
document.write(req.responseText);

The third argument of false is found in the CouchDB.request function
in the test suite xhr client. I think without false you have to supply
a callback.

http://svn.apache.org/repos/asf/couchdb/trunk/share/www/script/couch.js

Good luck and enjoy!

Chris
Reply all
Reply to author
Forward
0 new messages