On Aug 2, 2009, at 4:15 AM, Nitin Borwankar <[email protected]> wrote:
Paul Davis wrote:
On Sun, Aug 2, 2009 at 4:07 AM, Nitin
Borwankar<[email protected]> wrote:
Paul Davis wrote:
On Sun, Aug 2, 2009 at 3:44 AM, Nitin
Borwankar<[email protected]>
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
Try upping your log verbosity to debug and double checking that the
header made it through. If not its definitely jquery land, but may
point to something like a misspelled contentType or something.
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.
Might add this as a frequently asked question unless you see a
better place.
How about a wiki page for using jQuery ajax with CouchDB - this is
likely to be of wider interest.
Nitin
Well, for jquery with couchdb I'd just point people at jquery.couch.js
for most answers. Though that could be me being lazy. Feel free to add
where you think is appropriate. The wiki is a wiki after all. :)
Paul
Nitin