incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mike <>
Subject jquery ajax: json vs jsonp
Date Sun, 30 Jan 2011 23:41:55 GMT
I just started exploring couchDB and ran into this problem.  I am trying to
access some stuff on my newly created database.  I just want to
learn how to fetch the names of the databases I have created  using an ajax
call from a client browser running on a local pc.

Using jQuery (in Firexox) in the firebug command window I run this:

test = function(){
  url = "";
   url: url,
   dataType: 'jsonp',
   success: ( function(Response){ console.log(26, 'response is: ',
        Response) } ),
   error: function(XMLHttpRequest, textStatus, errorThrown){alert("Error");

I receive the following reply from the server:
HTTP/1.1 200 OK
Server: CouchDB/1.0.2 (Erlang OTP/R14B)
Date: Sun, 30 Jan 2011 22:52:29 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 55
Cache-Control: must-revalidate

In all cases I see a status code of 200OK.  (note odd content type).

(1) the success handler DOES NOT trigger.  Nothing appears in the console
(2) In the NET tab I see the data *has been* returned both in JSON format
and as an array (under the RESPONSE tab)


(3) I see no way [?]to access the returned data in my program.  It is
not in the DOM and there is no variable I can find that contains the
response data.

Now if I change the ajax dataType request to just json

dataType: 'jsonp', to dataType: 'json',


(1) the success handler fires

(2) BUT  NO is data returned

(3) and I get this in response headers

HTTP/1.1 200 OK
Server: CouchDB/1.0.2 (Erlang OTP/R14B)
Date: Sun, 30 Jan 2011 22:55:05 GMT
Content-Type: application/json
Content-Length: 55
Cache-Control: must-revalidate

I think jsonP is required because this seems to be a cross-domain
request.  But either I am missing something or perhaps CouchDB is not
setup to handle the callback processing required by jsonp requests.

Any help, advice, beer appreciated....

Also, I can not find any examples or documentation for:

jquery.couch.js (the jQ plugin)


couch.js (that ships with the couchDB installation).

Pointers to docs/examples much appreciated.

Mike Behar

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message