I found the answer here to the question below.
I needed to setup a reverse proxy in apache which took about 2 minutes by adding the following line to my virual host;
ProxyPass /couchdb/ http://dojo:5984/
Because of the same origin policy you can't post data across ports. I knew this applied to domains but not different ports so you set up a reverse proxy.
I would like to know how I can POST data to couchDB using JavaScript or jQuery.
I followed this tut and created a database and I'm able to post and get data using curl and it all works fine. There are curl examples below that I used.
I'm also able to get data using jQuery but I don't know how to POST to CouchDB
curl -X GET http://127.0.0.1:5984/mycouchshop/_all_docs.
curl -X POST http://127.0.0.1:5984/mycouchshop/ -d @person.json -H "Content-Type: application/json"
I'm able to get and display data using jQuery. The code below works fine.
$.ajax({
url : 'http://couchdb:5984/mycouchshop/_design/peoples/_view/people',
type : 'GET',
dataType : "jsonp",
success : function(json) {}
});
But posting data results in a 405 Method Not Allowed
$.ajax({
url : 'http://couchdb:5984/mycouchshop/',
data : {"forename": "Bob", "surname": "McHamster", "type": "person"},
contentType : "application/json",
type : 'POST',
dataType : "json",
success : function(resp) {}
});