You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Matthew Wilson <ma...@tplus1.com> on 2008/12/17 03:13:08 UTC

javascript on localhost can't access localhost:5984?

I'm working on an html page hosted on localhost that uses javascript
to pull some data from my local couchdb.

I guess I'm running into the cross-domain issue, because I'm getting
an error "access to restricted URI denied."

Anyhow, if I want to interact with couchdb using javascript, how do I
do it?  do I need to keep my HTML file in couchdb itself?

Matt

-- 
Matthew Wilson
matt@tplus1.com
http://tplus1.com

Re: javascript on localhost can't access localhost:5984?

Posted by Chris Anderson <jc...@gmail.com>.
Matt,

It's easy to store html in attachments to couchdb docs. For some
examples about how to do it, check out this github project, which is
an ajax blog that lives on couchdb

http://github.com/jchris/couchdb-example-blog/tree/master

It uses a Ruby script which is part of my CouchRest library to upload
a directory structure into a design document. It's considered good
practice to keep all the components of an application in a single
design doc. This way, index.html and your views will replicate
together, etc.

Jan is working on a Python port of the `couchapp` script so hopefully
the install story will get cleaner.

Chris

On Tue, Dec 16, 2008 at 6:13 PM, Matthew Wilson <ma...@tplus1.com> wrote:
> I'm working on an html page hosted on localhost that uses javascript
> to pull some data from my local couchdb.
>
> I guess I'm running into the cross-domain issue, because I'm getting
> an error "access to restricted URI denied."
>
> Anyhow, if I want to interact with couchdb using javascript, how do I
> do it?  do I need to keep my HTML file in couchdb itself?
>
> Matt
>
> --
> Matthew Wilson
> matt@tplus1.com
> http://tplus1.com
>



-- 
Chris Anderson
http://jchris.mfdz.com

Re: javascript on localhost can't access localhost:5984?

Posted by Andrew Tetlaw <an...@tetlaw.id.au>.
I'm on Mac OS X, so I just setup a reverse proxy/URL rewriting for the  
built-in apache server.

so that, say, my local app is at http://locahost/app, all the Ajax  
requests are made to http://locahost/app/db

I used this example to help me:
http://scratchpad.cmlenz.net/c46dc41f72de36121197c6e03ddbf978/

Thanks Mr Lenz, worked like a charm.


On 17/12/2008, at 1:13 PM, Matthew Wilson wrote:

> I'm working on an html page hosted on localhost that uses javascript
> to pull some data from my local couchdb.
>
> I guess I'm running into the cross-domain issue, because I'm getting
> an error "access to restricted URI denied."
>
> Anyhow, if I want to interact with couchdb using javascript, how do I
> do it?  do I need to keep my HTML file in couchdb itself?
>
> Matt
>
> -- 
> Matthew Wilson
> matt@tplus1.com
> http://tplus1.com



--
Andrew
http://tetlaw.id.au




Re: javascript on localhost can't access localhost:5984?

Posted by Andrew Tetlaw <an...@tetlaw.id.au>.
I got it working on my MacBook just using the built-in apache server  
and setting up a virtual host/reverse proxy.

So my say app was at localhost/app, all the Ajax requests went to  
localhost/app/db

I got the tip from here:

http://scratchpad.cmlenz.net/c46dc41f72de36121197c6e03ddbf978/



On 17/12/2008, at 1:13 PM, Matthew Wilson wrote:

> I'm working on an html page hosted on localhost that uses javascript
> to pull some data from my local couchdb.
>
> I guess I'm running into the cross-domain issue, because I'm getting
> an error "access to restricted URI denied."
>
> Anyhow, if I want to interact with couchdb using javascript, how do I
> do it?  do I need to keep my HTML file in couchdb itself?
>
> Matt
>
> -- 
> Matthew Wilson
> matt@tplus1.com
> http://tplus1.com



--
Andrew
http://tetlaw.id.au




Re: javascript on localhost can't access localhost:5984?

Posted by Bahadır Yağan <ba...@gmail.com>.
There is an other method called JSONP. It was asked a couple of times
before. But I don't know if it is implemented yet.

http://couchdb.markmail.org/search/?q=jsonp


Bahadir

On Thu, Dec 18, 2008 at 3:30 AM, Jan Lehnardt <ja...@apache.org> wrote:

>
> On 17 Dec 2008, at 15:14, Matthew Wilson wrote:
>
>  On Tue, Dec 16, 2008 at 9:13 PM, Matthew Wilson <ma...@tplus1.com> wrote:
>>
>>> I'm working on an html page hosted on localhost that uses javascript
>>> to pull some data from my local couchdb.
>>>
>>
>> After I wrote this, I found this blog post that mentioned the built-in
>> web server inside couchdb:
>>
>>
>> http://jan.prima.de/~jan/plok/archives/108-Programming-CouchDB-with-Javascript.html<http://jan.prima.de/%7Ejan/plok/archives/108-Programming-CouchDB-with-Javascript.html>
>>
>> Is this still a recommended method?
>>
>
> Yes.
>
> Cheers
> Jan
> --
>

Re: javascript on localhost can't access localhost:5984?

Posted by Jan Lehnardt <ja...@apache.org>.
On 17 Dec 2008, at 15:14, Matthew Wilson wrote:

> On Tue, Dec 16, 2008 at 9:13 PM, Matthew Wilson <ma...@tplus1.com>  
> wrote:
>> I'm working on an html page hosted on localhost that uses javascript
>> to pull some data from my local couchdb.
>
> After I wrote this, I found this blog post that mentioned the built-in
> web server inside couchdb:
>
> http://jan.prima.de/~jan/plok/archives/108-Programming-CouchDB-with-Javascript.html
>
> Is this still a recommended method?

Yes.

Cheers
Jan
--

Re: javascript on localhost can't access localhost:5984?

Posted by Matthew Wilson <ma...@tplus1.com>.
On Tue, Dec 16, 2008 at 9:13 PM, Matthew Wilson <ma...@tplus1.com> wrote:
> I'm working on an html page hosted on localhost that uses javascript
> to pull some data from my local couchdb.

After I wrote this, I found this blog post that mentioned the built-in
web server inside couchdb:

http://jan.prima.de/~jan/plok/archives/108-Programming-CouchDB-with-Javascript.html

Is this still a recommended method?


-- 
Matthew Wilson
matt@tplus1.com
http://tplus1.com