And if I had scrolled down further and put 2 and 2 together. You must be making 
a cross origin request. If OPTIONS is returning with 405 the address in the 
browser is different than your CouchDB. More on Cross Origin Resource Sharing 
here: http://www.w3.org/TR/cors/

AFAIK CouchDB still doesn't support CORS except via JSONP which you can enable 
(I hear it's on a wish list tho!). However, I don't think the jquery.couch yet 
supports JSONP either. If you need to do XSS then, I remember hacking it a 
while back to support JSONP 
https://github.com/jimklo/lrchart/blob/master/lr-stats/_attachments/scripts/jquery.couch-patched.js
 but don't recall how complete it is.

There's a list and show function modification that can be made to support CORS, 
but not sure where that snippet lives in the Internet ether. 

- Jim



Sent from my iPad

On May 19, 2012, at 9:19 PM, "Jim Klo" <[email protected]> wrote:

> An OPTIONS request is made by your browser when you make a Cross Origin 
> Request. Is your App on the same domain and port as CouchDB?
> 
> Sent from my iPad
> 
> On May 19, 2012, at 3:51 PM, "Hankey, Chris" <[email protected]> 
> wrote:
> 
>> This is just some more info.  Where is "OPTIONS" coming from?  It looks like 
>> the view function tries to use GET, but we end up with OPTIONS.
>> 
>> OPTIONS http://test:5984/forms/_design/formlist/_view/formlist HTTP/1.1
>> Host: test:5984
>> Connection: keep-alive
>> Access-Control-Request-Method: GET
>> Origin: null
>> User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like 
>> Gecko) Chrome/18.0.1025.168 Safari/535.19
>> Access-Control-Request-Headers: origin, content-type, accept
>> Accept: */*
>> Accept-Encoding: gzip,deflate,sdch
>> Accept-Language: en-US,en;q=0.8
>> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
>> 
>> 
>> -----Original Message-----
>> From: Hankey, Chris [mailto:[email protected]] 
>> Sent: Saturday, May 19, 2012 5:54 PM
>> To: [email protected]
>> Subject: Call to View returns 405. It's using OPTIONS not GET
>> 
>> I'm trying to call a view using the CouchDB Javascript API.  The $db.view 
>> call is failing with a "405 Method Not Allowed" error.  $db.view is 
>> generating the correct URL, but the call appears to be failing because the 
>> view function is using HTTP OPTIONS method ( or maybe JQuery).  If I change 
>> the HTTP method to GET & manually send the HTTP request, then it works fine. 
>>  I need $db.view to generate a GET.  Any thoughts?
>> 
>> Thanks
>> 
>> Chris
>> 
>> -----------
>> Sample Code
>> -----------
>> 
>> $.couch.urlPrefix ="http://test:5984";
>> $db = $.couch.db("forms");
>> 
>> 
>> function GetFormList() {  
>>  $("div#forms").empty();  
>>  $db.view("formviews/formlist", {  
>>   success: function(data) {  
>>    for (i in data.rows) {  
>>     id = data.rows[i].id;  
>>     html = '<div class="form">' +  
>>      '<span class="form">' + id + '</span> ' +  
>>      '<a href="#" class="edit">edit</a> '+  
>>      '<a href="#" class="delete">delete</a> '+  
>>      '</div>';  
>>     $("div#forms").append(html);  
>>    }  
>>  }});  
>> }  
>> 
>> 
>> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to