couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David M. W. Martin" <david.mar...@lymegreen.co.uk>
Subject Re: simple AJAX request
Date Wed, 19 Jan 2011 17:04:23 GMT
On Tue, 2011-01-18 at 18:33 -0800, Chris Johnson wrote:
> I am new to couchdb and have been successfully using it with the python 
> libs. I am trying to move to JS, which I am new to as well, and having 
> some challenges. I know this is a simple question, so please bare with 
> me. I am trying to make a simple ajax call to pull data from a view but 
> get an error. I have tried with both the full URL and just he view 
> information with no luck. What am I missing?
> 
> <script type="text/javascript" charset="utf-8">
>           $.getJSON("_view/status", function(data) {
>              alert("JSON Data: " + data);
>            });
> </script>
> 

seems you have not specified your database
this snippet got 20 jpg images and appended them to a
html div target

        var  i, database = "/otperl_array_of_urls_020/",
        command = "_all_docs",
        startkeyVal = "\"2000-10-11-11-26-32-0\"",
        endkeyVal = "\"2000-10-12-08-55-35-0\"",
        limitVal = 20,
        mytarget1 = $('div#thumbnails');
        
        
        $.getJSON(database + command, 
                   {startkey: startkeyVal, 
                    endkey: endkeyVal, 
                     limit: limitVal }, 
                      function (data, status) {
               mytarget1.html(
               "<img src=\"/otperl_array_of_urls_020/" + 
               data.rows[0].id + "/th_" +
               data.rows[0].key + ".jpg\"/>" 
               );

              for (i = 1;  i < limitVal; i = i + 1) { 
                    mytarget1.append(
               "<img src=\"/otperl_array_of_urls_020/" + 
               data.rows[i].id + "/th_" +
               data.rows[i].key + ".jpg\"/>" 
              ); 
                
                };
            });  //end of getJSON
-- 
Sent from Ubuntu


Mime
View raw message