You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by wh...@aol.com on 2010/08/10 09:06:15 UTC
get view json into javascript variable
How can I get a view into a javascript variable on an html page?
I have a web based json viewer but I need to get the view json out
of couchdb and into a javascript variable on the webpage to make it work.
Thanks,
Dan
I can't figure out how to do this from the documentation or hours of browsing around and reading the two couchdb books.
Thanks,
Re: get view json into javascript variable
Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Aug 10, 2010 at 9:06 AM, <wh...@aol.com> wrote:
>
> How can I get a view into a javascript variable on an html page?
> I have a web based json viewer but I need to get the view json out
> of couchdb and into a javascript variable on the webpage to make it work.
>
> Thanks,
>
> Dan
>
> I can't figure out how to do this from the documentation or hours of browsing around and reading the two couchdb books.
>
> Thanks,
>
>
You can get the json via ajx and render the view then.
- benoit
Re: get view json into javascript variable
Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 10 August 2010 19:06, <wh...@aol.com> wrote:
>
> How can I get a view into a javascript variable on an html page?
> I have a web based json viewer but I need to get the view json out
> of couchdb and into a javascript variable on the webpage to make it work.
>
> Thanks,
>
> Dan
>
> I can't figure out how to do this from the documentation or hours of browsing around and reading the two couchdb books.
Well I am a crap javascript programmer (think duplo building blocks)
but this works for me - is this what you were missing?
<script type="text/javascript">
$.getJSON("/mydb/dave@example.org", function(json){
alert(json.name + " lives in " + json.location + " and you can fax
to " + json.fax);
});
</script>
& the doc on the couch:
{
"_id": "dave@example.org",
"type": "contact",
"site": "NZL.Wellington",
"phone": "+64 4 9727208",
"fax": "+64 4 9727123",
"name": "Dave Cottlehuber"
}
It should be the same for a view, your URL will be different.
cheers
Dave