gpt4 book ai didi

jquery - 关于用户空间中的 CouchJS 的简单示例,例如使用浏览器?

转载 作者:行者123 更新时间:2023-12-01 03:19:55 25 4
gpt4 key购买 nike

定义

CouchJs : the JavaScript interpreter for CouchDB

CouchDB : a NonSQL db where you execute most things in user-space with things such as JS because things tend to be expensive to execute on the database-level

Integrity : In information security, integrity means that data cannot be modified undetectably. More here.

CouchJS website没有内部搜索,在谷歌搜索或多或少令人困惑的博客文章后,我迷失了方向。我在哪里可以找到一些简单的例子(不仅仅是 curl /远程登录),如下所示?

<script type="text/javascript" src="lib/jquery-1.7.2.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.21.custom.min.js"></script>
<script src="http://127.0.0.1:5984/_utils/script/jquery.couch.js"></script>
//# 1. initilalize the db -object
//# 2. save something to the db with the object
<script> db.test.save('hello world') </script>

也许对其他新手有用

  1. CouchDB a real world example ,引用免费书籍等的帖子

  2. NonSQL: initialization of DB -object in browser console? DB -logic in the user-space?

  3. CouchJS 源代码 here .

  4. https://stackoverflow.com/questions/11077093/what-are-ajax-options-in-couchjs-explain-this-odd-null-error-with-couchjs

最佳答案

建立在弗洛里安答案之上——因为当我指出一些错误时他删除了他的答案here请浏览一下他在历史上的回答。他推荐了有关文档更新处理程序的文章 here和示例 here 。至少有两个问题,XMLHttpRequest here需要一个字符串,而不是对象——我编辑了他的答案以添加 XMLHttpRequest -手册以进行进一步调查,但由于某种原因有人取消了编辑。因此,我正在制作自己的答案,其中包含最多的修复,但仍然令人恼火的 DOM 11,我仍在尝试解决。

// By this function we solve the problem with Object, 
// changing JSON -object to string. The source is:
// https://stackoverflow.com/questions/111529/create-query-parameters-in-javascript
function EncodeQueryData(data)
{
var ret = [];
for (var d in data)
ret.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
return ret.join("&");
}

// We use ready CouchDB -example, source:
// http://wiki.apache.org/couchdb/HTTP_Document_API#PUT
var datas = {
"Subject":"I like Plankton",
"Author":"Rusty",
"PostedDate":"2006-08-15T17:30:12-04:00",
"Tags":["plankton", "baseball", "decisions"],
"Body":"I decided today that I don't like baseball. I like plankton."
};

// We use the default -function, please, see the O'Reilly.
// https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest
var xhr = new XMLHttpRequest();

// This may be wrong
xhr.open( 'POST', 'test.js', true );
xhr.setRequestHeader( 'Content-Type', 'application/json' );
xhr.open( 'POST', '127.0.0.1:5984/test/559c327683fe0acb96aff72bd174c258', true);

var msg = EncodeQueryData(datas);
xhr.send(msg);

待办事项

  • Now there is one error XMLHttpRequest "does not handle nested objects" but string so we need either more complex command or arrayswith XMLHttpRequest. I thank C.*rk for helping me with this.
  • Probably RELATING TO test.js, under investigation the err: "XMLHttpRequest cannot load %3127.0.0.1:5984/test/559c327683fe0acb96aff72bd174c258. Cross origin requests are only supported for HTTP. Error: NETWORK_ERR: XMLHttpRequest Exception 101"

相关谜题

  1. [已解决] Explain DOM 11 error in the initialization of XMLHttpRequest with JSON -headers

关于jquery - 关于用户空间中的 CouchJS 的简单示例,例如使用浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11076076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com