Creating a New Document Using AJAX

The couchapp framework comes with some excellent libraries for managing your Couch DBs. If you're developing a couchapp, the URIs to the needed JS will be along the lines:

<script src="/_utils/script/json2.js"></script>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>

To create a new document, you can then just do:

<script type="text/javascript">
  var hitData = {
  "publication_id" : "1",
  "content_id" : "66",
  "section_id" : "22",
  "created_at" : "",
  "uri" : "/hit.html"
  };

  var $db = $.couch.db("memento");
      $db.saveDoc(hitData);
</script>

~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert