From user-return-5766-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Aug 02 08:14:58 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 88079 invoked from network); 2 Aug 2009 08:14:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Aug 2009 08:14:58 -0000 Received: (qmail 73276 invoked by uid 500); 2 Aug 2009 08:15:01 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 73190 invoked by uid 500); 2 Aug 2009 08:15:00 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 73178 invoked by uid 99); 2 Aug 2009 08:15:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Aug 2009 08:15:00 +0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [66.111.4.25] (HELO out1.smtp.messagingengine.com) (66.111.4.25) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Aug 2009 08:14:50 +0000 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 853643B0EC3; Sun, 2 Aug 2009 04:14:29 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 02 Aug 2009 04:14:30 -0400 X-Sasl-enc: 7yLd6l1c3xqH8y8sCKNoeSCEuyGVeFHOQICyFF5YnQE9 1249200870 Received: from NitinBorwankarsComputer.local (c-71-202-180-50.hsd1.ca.comcast.net [71.202.180.50]) by mail.messagingengine.com (Postfix) with ESMTPA id 4870B1BE4 for ; Sun, 2 Aug 2009 04:14:30 -0400 (EDT) Message-ID: <4A754AE4.3020001@borwankar.com> Date: Sun, 02 Aug 2009 01:14:28 -0700 From: Nitin Borwankar User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: couch returning text/plain for responses - is this correct ? References: <4A7543F2.7030804@borwankar.com> <4A754931.70207@borwankar.com> In-Reply-To: <4A754931.70207@borwankar.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Nitin Borwankar wrote: > Paul Davis wrote: >> On Sun, Aug 2, 2009 at 3:44 AM, Nitin Borwankar >> wrote: >> >>> Starting a separate thread as this was discovered at the end of a long >>> thread about jQuery/callback=? etc. >>> >>> Here's what I am seeing. Wondering if this is supposed to be this >>> way and >>> why that might be ? >>> >>> curl -v http://localhost:5984/ >>> >>> * About to connect() to localhost port 5984 (#0) >>> * Trying 127.0.0.1... connected >>> * Connected to localhost (127.0.0.1) port 5984 (#0) >>> >>>> GET / HTTP/1.1 >>>> User-Agent: curl/7.19.3 (i386-apple-darwin9.6.0) libcurl/7.19.3 >>>> zlib/1.2.3 >>>> Host: localhost:5984 >>>> Accept: */* >>>> >>>> >>> < HTTP/1.1 200 OK >>> < Server: CouchDB/0.9.0 (Erlang OTP/R12B) >>> < Date: Sun, 02 Aug 2009 07:42:07 GMT >>> < Content-Type: text/plain;charset=utf-8 >>> <-------===============--------- >>> note text/plain >>> < Content-Length: 40 >>> < Cache-Control: must-revalidate >>> < >>> {"couchdb":"Welcome","version":"0.9.0"} >>> * Connection #0 to host localhost left intact >>> * Closing connection #0 >>> >>> >>> This appears to be the same for results of views etc as well. >>> >>> I am on CouchDBX 0.9.0 on Intel Leopard 10.5.7 >>> >>> Thanks, >>> >>> Nitin >>> >>> >>> >>> >>> >>> >> >> Yep this is expected because if we return application/json by default >> then browsers will prompt users to download instead of displaying the >> output. There were a couple awesome bike shed discussions on it. See >> also the end responses with a newline threads if you're feeling >> masochistic. >> >> For reference the end result was return text/plain unless the client >> asks for application/json. >> >> Paul >> > > > > OK, so curl -v -H gives me the right response - but setting teh > contentType in $.ajax() still gives a text/plain back which I have to > JSON.parse(). > > This may be a jQuery issue - in any case > > a) I know how to get it to work > b) I know now why it has to be that way - I figured it was related to > making it easire to debug and just to see what was happening. > Right decision I think but it might help to document prominently in > the wiki. Happy to write something up if you tell me the right place > to put it. > > Nitin > > > > OK, so here's the problem - $.ajax wants a dataType param not a contentType. The following works $.ajax({ type: "GET", url: "http://localhost:5984/, dataType: "json", success: function(data){ alert(data.version); }, error: function(data){ alert('try harder'); } }); This is a good test piece of code and should return the version number of your couch instance assuming a default location and port. Again happy to document on wiki given some direction as to the right place. Nitin