Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 7224 invoked from network); 30 Jan 2011 23:42:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jan 2011 23:42:40 -0000 Received: (qmail 73566 invoked by uid 500); 30 Jan 2011 23:42:39 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 73480 invoked by uid 500); 30 Jan 2011 23:42:38 -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 73472 invoked by uid 99); 30 Jan 2011 23:42:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Jan 2011 23:42:38 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of withforesight@gmail.com designates 209.85.215.180 as permitted sender) Received: from [209.85.215.180] (HELO mail-ey0-f180.google.com) (209.85.215.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Jan 2011 23:42:37 +0000 Received: by eyf18 with SMTP id 18so2128862eyf.11 for ; Sun, 30 Jan 2011 15:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:x-goomoji-body:date :message-id:subject:to:content-type; bh=8h5RI3L7Z9/zq2Tq5bIfh1nnYokW5zMi2DnYhi2XwxY=; b=Fe8VQdCxY20+nIkhtt5cLFN45fX7OZ9/hBab93DMSJnIAJWRu+Ef4tgM0nH2jLstJo WZmDK/gD+Cvc9TIh8n2hIQNbRSKfeXPxluBZKikDmEaF/1bFCNYwFr7TBqS2lCmuAceH qWVEZOTlNV9hPjZCoT316kScIyQVEmKYY3zYA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:x-goomoji-body:date:message-id:subject:to :content-type; b=vEdoLmVZrVaDEY2IP06m3afET4r91tDN9ipE/Pa0R3BuGmHNVKdrgkn0uFpWBlSyQd cnRMR0kEpc8JHG5RBGhUVbFfD9FNyQnS2maluBmHkxSkjphq5xteoSrRbU/qzbRyavlU ja55XBW4A/hZqz3PwHFWLLqRKm5PQtTCvw5l0= Received: by 10.14.122.79 with SMTP id s55mr6227451eeh.32.1296430935852; Sun, 30 Jan 2011 15:42:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.14.119.7 with HTTP; Sun, 30 Jan 2011 15:41:55 -0800 (PST) From: mike X-Goomoji-Body: true Date: Sun, 30 Jan 2011 18:41:55 -0500 Message-ID: Subject: jquery ajax: json vs jsonp To: user@couchdb.apache.org Content-Type: multipart/related; boundary=e0cb4e70021b6847dc049b18d9f4 --e0cb4e70021b6847dc049b18d9f4 Content-Type: multipart/alternative; boundary=e0cb4e70021b6847d6049b18d9f3 --e0cb4e70021b6847d6049b18d9f3 Content-Type: text/plain; charset=ISO-8859-1 I just started exploring couchDB and ran into this problem. I am trying to access some stuff on my newly created couchone.com 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 = "http://withforesight.couchone.com/_all_dbs"; $.ajax({ url: url, dataType: 'jsonp', success: ( function(Response){ console.log(26, 'response is: ', Response) } ), error: function(XMLHttpRequest, textStatus, errorThrown){alert("Error"); } }); }; test() 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). However: (1) the success handler DOES NOT trigger. Nothing appears in the console log. (2) In the NET tab I see the data *has been* returned both in JSON format and as an array (under the RESPONSE tab) ["test_suite_reports","test_suite_db","mike","_users"] (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', then: (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. (see: http://remysharp.com/2007/10/08/what-is-jsonp/) Any help, advice, beer appreciated.... Also, I can not find any examples or documentation for: jquery.couch.js (the jQ plugin) and couch.js (that ships with the couchDB installation). Pointers to docs/examples much appreciated. Mike Behar --e0cb4e70021b6847d6049b18d9f3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I just started exploring couchDB and ran into this problem. =A0I am trying = to access some stuff on my newly created co= uchone.com database. =A0I just want to learn how to fetch the names of = the databases I have created =A0using an ajax call from a client browser ru= nning on a local pc.

Using jQuery (in Firexox) in the firebug command window I ru= n this:

test =3D function(){
=A0=A0url =3D "http://withforesight.couchone.com/_all_dbs";=A0<= /div>
=A0$.ajax({
=A0=A0 url: url,
=A0=A0 dataTyp= e: 'jsonp',
=A0=A0 success: ( function(Response){ console.log(26, '= response is: ', =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Response) } ),
=A0=A0 error: function(XMLHttpRequest, textStatus, = errorThrown){alert("Error"); }
});
};
test() =A0=A0
=

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

In all cases I see a status code of 200OK. =A0(no= te odd content type).
=A0
However:=A0
(1) the= success handler DOES NOT trigger. =A0Nothing appears in the console log.= =A0
(2) In the NET tab I see the data has been returned both in JSO= N format and as an array (under the RESPONSE tab)=A0
["test_suite_reports","test_suite_=
db","mike","_users"]
(3)=A0I see no way to access the =
returned data in my program. =A0It is not in the DOM and there is no variab=
le I can find that contains the response data.
Now if I change the ajax dataType request to just json=A0
dataType:=A0'jsonp', to=A0dataType:=
=A0'json',
then:=A0
(1) the success handler =
fires
(2) BUT =A0NO is data returned=A0
(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 c=
ross-domain request. =A0But either I am missing something or perhaps CouchD=
B is not setup to handle the callback processing required by jsonp requests=
. (see:=A0http://remysharp.com/2007/10/08/what-is-jsonp/)
Any help, advice, beer appreciat=
ed....

Also, I can n=
ot find any examples or documentation for:
jquery.couch.js (the jQ plugin) =A0
and=A0
couch.js (that ships with the couchDB in=
stallation). =A0=A0
Pointers to docs/examples much ap=
preciated.


Mike Behar













--e0cb4e70021b6847d6049b18d9f3-- --e0cb4e70021b6847dc049b18d9f4--