You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Ben Johnson <my...@gmail.com> on 2014/02/20 07:06:57 UTC

A POST from the browser

Hello,
  I am new to couchdB and am exploring it as a way to store some data.  I
would like to store data that originates from the browser into my database.
 It seems from all forms of ajax calls I have tried it posts the OPTIONS
method before the POST to test the waters.  It looks like couch never
accepts this method because it is not allowed (405).

What is the simplest  way to POST docs to the database from the browser
using ajax?  Can it handle the OPTIONS method?

Thanks for your help,
Ben

Re: A POST from the browser

Posted by Aurélien Bénel <au...@utt.fr>.
Hi Ben,

> It seems from all forms of ajax calls I have tried it posts the OPTIONS method before the POST to test the waters.  It looks like couch never accepts this method because it is not allowed (405).

1. Is the URI correct in your ajax call?
(see http://docs.couchdb.org/en/latest/api/database/common.html#post--db )

2. Is CORS enabled? Is your origin allowed?
(see http://docs.couchdb.org/en/latest/config/http.html#cors )


Regards,

Aurélien

Re: A POST from the browser

Posted by Ben Johnson <my...@gmail.com>.
Thanks all for the suggestions.  I did finally get my POST into the
database by disabling the crossDomain on the browser side code.  I did have
cors enabled on CouchDB which I thought should have allowed the database to
respond better to the OPTIONS requests than a 405?  I originally was
running an older version of CouchDB that looked like it did not support
CORS but then upgraded to 1.5.0 and still had this issue.

Thanks again.  I have one other question but unrelated so I will post on a
different thread.


On Thu, Feb 20, 2014 at 11:08 AM, Russell Branca <ch...@apache.org>wrote:

> Hi Ben,
>
>
> Your browser making OPTIONS requests is indicative of a cross domain
> request that requires CORS to be enabled within CouchDB. The issue is that
> by default in the browser, you can't make an ajax request from one domain
> to another.
>
>
> -Russell
>
>
> On Thu, Feb 20, 2014 at 12:09 AM, I.R. <th...@googlemail.com> wrote:
>
> >
> > > What is the simplest  way to POST docs to the database from the browser
> > > using ajax?
> >
> > open /_utils and use Futon's JQuery lib inside the browser console to
> POST
> > via Ajax - this should prevent you from the x-domain issue
>

Re: A POST from the browser

Posted by Russell Branca <ch...@apache.org>.
Hi Ben,


Your browser making OPTIONS requests is indicative of a cross domain
request that requires CORS to be enabled within CouchDB. The issue is that
by default in the browser, you can't make an ajax request from one domain
to another.


-Russell


On Thu, Feb 20, 2014 at 12:09 AM, I.R. <th...@googlemail.com> wrote:

>
> > What is the simplest  way to POST docs to the database from the browser
> > using ajax?
>
> open /_utils and use Futon's JQuery lib inside the browser console to POST
> via Ajax - this should prevent you from the x-domain issue

Re: A POST from the browser

Posted by "I.R." <th...@googlemail.com>.
> What is the simplest  way to POST docs to the database from the browser
> using ajax? 

open /_utils and use Futon's JQuery lib inside the browser console to POST via Ajax - this should prevent you from the x-domain issue