1

I run this code here

<html>

<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>
<!--<script type="text/javascript" src="lib/jquery-1.7.2.js"></script>-->

<script>
<!--var dbc = $.jqCouch.connection('db');-->
<!--dbc.exists('database_name');-->

<!--if ($.jqCouch.connection('db').create('database_name').ok) {-->
    <!--alert("database created");-->
<!--}-->

$.couch.activeTasks({
  success: function (data) {
    console.log(data);
  }
});
</script>

</html>

and I get the error. I have tried with all kind of jQueries such as everything with UI -custom and the 1.72 as you can see in the code. So why do I get this error? And where can I find which jQuery is needed to use the CouchJS?

Puzzles

  1. Joy solved the jQuery -problem picture here.

  2. Now some odd type-error here and source here.

Perhaps useful to other beginners with CouchDB

  1. Simple example about CouchJS in userspace for example with Browser?

  2. Easy way to tell which JQuery functions are needed?

  3. Where do you include the jQuery library from? Google JSAPI? CDN?

Community
  • 1
  • 1
hhh
  • 50,788
  • 62
  • 179
  • 282

2 Answers2

2

You need to load jQuery before, jQuery UI or Couch JS because they both uses $ variable inside those files, and jQuery.js defines that $ as an alias to the jQuery object. So $ has to be defined first before being used. So change your code to this

<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>

And it should Work fine.

For production websites I would recommend loading jQuery from a CDN( You can do a quick google search to find the benefits of using CDN for jQuery if you dont already know) like

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
Prasenjit Kumar Nag
  • 13,391
  • 3
  • 45
  • 57
1

Please include jQuery before jquery.couch.js.

xdazz
  • 158,678
  • 38
  • 247
  • 274