You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Nitin Borwankar <ni...@borwankar.com> on 2009/08/02 03:57:32 UTC
callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Hello all,
I have been banging my head against this wall for 2 days and I finally made
a crack ---
Trying to use jQuery, $.ajax() in an app that calls couchdb api - not using
( cannot use ) couchapp must call from legacy app.
Couldn't get a successful response.
finally just put the get query into firefx and go the following which
explains why it's not working - but not a clue how to work around this.
get query:
http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
?
couch responds: {"error":"query_parse_error","reason":"Bad URL query
key:callback"}
I don't have the option to use either couch.js or jquery.couch.js but have
to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
Am I stuck without any help possible ?
Nitin
37% of all statistics are made up on the spot
-------------------------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Oliver Boermans <bo...@gmail.com>.
2009/8/2 Nitin Borwankar <ni...@borwankar.com>:
> yes I started with that - it's a long story but it comes down to couch
> returning content-type text plain in the HTTP response headers,
> so an extra JSON.parse() has to be applied to get json.
Ah… Thanks for sharing the work around – I expect that will prove to be useful.
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Aug 2, 2009 at 2:51 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Davis wrote:
>>>
>>> b) this is what I was doing before I tried to make it work with the
>>> file://
>>> But not using a callback=? param and using the following url - just to
>>> see
>>> if I can get any json at all -
>>>
>>> $.get("http://localhost:5984/", function(data){ alert(data); } );
>>>
>>> gives me an alert with nothing in it.
>>>
>>>
>>
>> Where are you loading this code from? Is it in an attachment on a doc
>> in CouchDB? Can you perhaps make a simple HTML doc with some AJAX in
>> it and try loading that from CouchDB to see what happens?
>>
>>
>
> yes it is is in an html doc and is under _attachments
> I invoke it via the url
>
> http://localhost:5984/ptest2/_design/vt2/index_1.html
>
> I made some progress - I added a type param "text" after the function
>
> $.get("http://localhost:5984/", function(data){ alert(data); }, "text" );
>
>
>
> and I do get the json as a string in the alert.
>
> but when the type is "json" and I try alert(data.version) or
> alert(data['version']) I get "undefined".
>
> $.get("http://localhost:5984/", function(data){ alert(data.version); },
> "json" );
> $.get("http://localhost:5984/", function(data){ alert(data['version']); },
> "json" );
>
> these give an alert that says "undefined".
>
> I have just been unable to get the browser to interpret the response from
> couch as "json".
>
Sounds like you've reached jQuery land in terms of weirdness. Though,
see if you can't add an "Accept: application/json" header to the XHR
or something to force CouchDB to return JSON which I think it does if
the accept is present. Someone more familiar could probably correct me
here though.
Paul
>
> Nitin
>
>> Paul
>>
>>
>>>
>>> Nitin
>>>
>>>>
>>>> Then you can just make AJAX call's directly from the page without
>>>> worrying about the callback parameter at all. This is probably what
>>>> you want.
>>>>
>>>> If not, then you'll need to upgrade.
>>>>
>>>> HTH,
>>>> Paul Davis
>>>>
>>>>
>>>>
>>>>>>
>>>>>> HTH,
>>>>>> Paul Davis
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Paul
>>>>>>>>
>>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin
>>>>>>>> Borwankar<ni...@borwankar.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Ntitn,
>>>>>>>>>>
>>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hey Paul,
>>>>>>>>>
>>>>>>>>> Thanks much
>>>>>>>>>
>>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>>
>>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>>
>>>>>>>>> Also assuming the answer is yes - in the new improved couch - do I
>>>>>>>>> just
>>>>>>>>> use
>>>>>>>>> the callback=? on the client request or do I have to do something
>>>>>>>>> in
>>>>>>>>> my
>>>>>>>>> views to set content-type? as well.
>>>>>>>>>
>>>>>>>>> Thanks much,
>>>>>>>>>
>>>>>>>>> Nitin
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Paul Davis
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Hello all,
>>>>>>>>>>>
>>>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>>>> finally
>>>>>>>>>>> made
>>>>>>>>>>> a crack ---
>>>>>>>>>>>
>>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api
>>>>>>>>>>> -
>>>>>>>>>>> not
>>>>>>>>>>> using
>>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>>
>>>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>>>> which
>>>>>>>>>>> explains why it's not working - but not a clue how to work around
>>>>>>>>>>> this.
>>>>>>>>>>>
>>>>>>>>>>> get query:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>>> ?
>>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>>> query
>>>>>>>>>>> key:callback"}
>>>>>>>>>>>
>>>>>>>>>>> I don't have the option to use either couch.js or jquery.couch.js
>>>>>>>>>>> but
>>>>>>>>>>> have
>>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON
>>>>>>>>>>> etc.
>>>>>>>>>>>
>>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>>
>>>>>>>>>>> Nitin
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>>> Nitin Borwankar
>>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Aug 2, 2009 at 3:48 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Davis wrote:
>>
>> On Sun, Aug 2, 2009 at 3:26 AM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>>
>>>
>>> Nitin Borwankar wrote:
>>>
>>>>
>>>> $.get("http://localhost:5984/", function(data){ alert(data.version); },
>>>> "json" );
>>>> $.get("http://localhost:5984/", function(data){ alert(data['version']);
>>>> },
>>>> "json" );
>>>>
>>>> these give an alert that says "undefined".
>>>>
>>>> I have just been unable to get the browser to interpret the response
>>>> from
>>>> couch as "json".
>>>>
>>>
>>> OK, finally success. I set the type to "json" and did a JSON.parse(data)
>>> on
>>> the data passed into the callback.
>>> It seems strange that this has to be explicitly done. This appears to be
>>> a
>>> content tye issue. I debugged this using curl -v more below.
>>>
>>>
>>> This is what worked
>>>
>>> include the script
>>> <script src="/_utils/script/json2.js"></script>
>>> amongst others
>>>
>>> $.get("http://localhost:5984/", function(data){
>>> alert(JSON.parse(data)['version']); }, "json" );
>>>
>>> this gives an alert with 0.9.0 as expected.
>>>
>>> So the major hurdle has been cleared.
>>>
>>> Paul many thanks again for your patience.
>>>
>>> Here's what I saw using curl -v pointing to just the base url for couchdb
>>>
>>> curl -v $CDBA
>>>
>>
>> Try this instead:
>>
>> curl -v -H 'Accept: application/json' http://127.0.0.1:5984/
>>
>> Peeping the jquery docs for $.get I don't see a way to set headers
>> there. Checking the jquery.couch.js it looks like it's doing something
>> like:
>>
>>
>> $.ajax({
>> type: "PUT",
>> url: this.uri,
>> contentType: "application/json",
>> ...
>> });
>>
>>
>
> OK so maybe I should just use $.ajax instead. $.get has a data param for
> k/v pairs to be sent in the request - content type may be settable via that
> - I'll try.
> Thanks much.
That looked like K/V parameters for a form upload so I ignored it.
>
> Just curious - any reason why the default return type is not
> application/json given that one of CouchDB's selling points is that it is a
> JSON/REST based data store ?
>
Just responded in the other thread. And mostly, just cause.
> Nitin
>
>
>> HTH,
>> Paul Davis
>>
>>
>>>
>>> * About to connect() to localhost port 5984 (#0)
>>> * Trying 127.0.0.1... connected
>>> * Connected to localhost (127.0.0.1) port 5984 (#0)
>>> * Server auth using Basic with user 'nitin'
>>>
>>>>
>>>> GET / HTTP/1.1
>>>> Authorization: Basic bml0aW46bjF0MW4=
>>>> 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:22:21 GMT
>>> < Content-Type: text/plain;charset=utf-8 <------------ note couch
>>> is
>>> returning a text/plain rather than application/json
>>> < Content-Length: 40
>>> < Cache-Control: must-revalidate
>>> <
>>> {"couchdb":"Welcome","version":"0.9.0"}
>>> * Connection #0 to host localhost left intact
>>> * Closing connection #0
>>>
>>> Not sure if there's a reason for this or this could be legitimately
>>> changed
>>> in 0.10
>>>
>>> Nitin
>>>
>>>
>>>
>>>
>>>
>>>
>>> Nitin
>>>
>>>
>>>
>>>
>>>>
>>>> Nitin
>>>>
>>>>
>>>>>
>>>>> Paul
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Nitin
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Then you can just make AJAX call's directly from the page without
>>>>>>> worrying about the callback parameter at all. This is probably what
>>>>>>> you want.
>>>>>>>
>>>>>>> If not, then you'll need to upgrade.
>>>>>>>
>>>>>>> HTH,
>>>>>>> Paul Davis
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>>
>>>>>>>>> HTH,
>>>>>>>>> Paul Davis
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Paul
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin
>>>>>>>>>>> Borwankar<ni...@borwankar.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Ntitn,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Hey Paul,
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks much
>>>>>>>>>>>>
>>>>>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>>>>>
>>>>>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>>>>>
>>>>>>>>>>>> Also assuming the answer is yes - in the new improved couch - do
>>>>>>>>>>>> I
>>>>>>>>>>>> just
>>>>>>>>>>>> use
>>>>>>>>>>>> the callback=? on the client request or do I have to do
>>>>>>>>>>>> something
>>>>>>>>>>>> in
>>>>>>>>>>>> my
>>>>>>>>>>>> views to set content-type? as well.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks much,
>>>>>>>>>>>>
>>>>>>>>>>>> Nitin
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Paul Davis
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar
>>>>>>>>>>>>> <ni...@borwankar.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hello all,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have been banging my head against this wall for 2 days and
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>> finally
>>>>>>>>>>>>>> made
>>>>>>>>>>>>>> a crack ---
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb
>>>>>>>>>>>>>> api
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> not
>>>>>>>>>>>>>> using
>>>>>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> finally just put the get query into firefx and go the
>>>>>>>>>>>>>> following
>>>>>>>>>>>>>> which
>>>>>>>>>>>>>> explains why it's not working - but not a clue how to work
>>>>>>>>>>>>>> around
>>>>>>>>>>>>>> this.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> get query:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>>>>>> ?
>>>>>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>>>>>> query
>>>>>>>>>>>>>> key:callback"}
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I don't have the option to use either couch.js or
>>>>>>>>>>>>>> jquery.couch.js
>>>>>>>>>>>>>> but
>>>>>>>>>>>>>> have
>>>>>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post,
>>>>>>>>>>>>>> $,getJSON
>>>>>>>>>>>>>> etc.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Nitin
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>>>>>> Nitin Borwankar
>>>>>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>
>>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Davis wrote:
> On Sun, Aug 2, 2009 at 3:26 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
>
>> Nitin Borwankar wrote:
>>
>>> $.get("http://localhost:5984/", function(data){ alert(data.version); },
>>> "json" );
>>> $.get("http://localhost:5984/", function(data){ alert(data['version']); },
>>> "json" );
>>>
>>> these give an alert that says "undefined".
>>>
>>> I have just been unable to get the browser to interpret the response from
>>> couch as "json".
>>>
>> OK, finally success. I set the type to "json" and did a JSON.parse(data) on
>> the data passed into the callback.
>> It seems strange that this has to be explicitly done. This appears to be a
>> content tye issue. I debugged this using curl -v more below.
>>
>>
>> This is what worked
>>
>> include the script
>> <script src="/_utils/script/json2.js"></script>
>> amongst others
>>
>> $.get("http://localhost:5984/", function(data){
>> alert(JSON.parse(data)['version']); }, "json" );
>>
>> this gives an alert with 0.9.0 as expected.
>>
>> So the major hurdle has been cleared.
>>
>> Paul many thanks again for your patience.
>>
>> Here's what I saw using curl -v pointing to just the base url for couchdb
>>
>> curl -v $CDBA
>>
>
> Try this instead:
>
> curl -v -H 'Accept: application/json' http://127.0.0.1:5984/
>
> Peeping the jquery docs for $.get I don't see a way to set headers
> there. Checking the jquery.couch.js it looks like it's doing something
> like:
>
>
> $.ajax({
> type: "PUT",
> url: this.uri,
> contentType: "application/json",
> ...
> });
>
>
OK so maybe I should just use $.ajax instead. $.get has a data param
for k/v pairs to be sent in the request - content type may be settable
via that - I'll try.
Thanks much.
Just curious - any reason why the default return type is not
application/json given that one of CouchDB's selling points is that it
is a JSON/REST based data store ?
Nitin
> HTH,
> Paul Davis
>
>
>> * About to connect() to localhost port 5984 (#0)
>> * Trying 127.0.0.1... connected
>> * Connected to localhost (127.0.0.1) port 5984 (#0)
>> * Server auth using Basic with user 'nitin'
>>
>>> GET / HTTP/1.1
>>> Authorization: Basic bml0aW46bjF0MW4=
>>> 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:22:21 GMT
>> < Content-Type: text/plain;charset=utf-8 <------------ note couch is
>> returning a text/plain rather than application/json
>> < Content-Length: 40
>> < Cache-Control: must-revalidate
>> <
>> {"couchdb":"Welcome","version":"0.9.0"}
>> * Connection #0 to host localhost left intact
>> * Closing connection #0
>>
>> Not sure if there's a reason for this or this could be legitimately changed
>> in 0.10
>>
>> Nitin
>>
>>
>>
>>
>>
>>
>> Nitin
>>
>>
>>
>>
>>> Nitin
>>>
>>>
>>>> Paul
>>>>
>>>>
>>>>
>>>>> Nitin
>>>>>
>>>>>
>>>>>> Then you can just make AJAX call's directly from the page without
>>>>>> worrying about the callback parameter at all. This is probably what
>>>>>> you want.
>>>>>>
>>>>>> If not, then you'll need to upgrade.
>>>>>>
>>>>>> HTH,
>>>>>> Paul Davis
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>> HTH,
>>>>>>>> Paul Davis
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Paul
>>>>>>>>>>
>>>>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin
>>>>>>>>>> Borwankar<ni...@borwankar.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Ntitn,
>>>>>>>>>>>>
>>>>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> Hey Paul,
>>>>>>>>>>>
>>>>>>>>>>> Thanks much
>>>>>>>>>>>
>>>>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>>>>
>>>>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>>>>
>>>>>>>>>>> Also assuming the answer is yes - in the new improved couch - do I
>>>>>>>>>>> just
>>>>>>>>>>> use
>>>>>>>>>>> the callback=? on the client request or do I have to do something
>>>>>>>>>>> in
>>>>>>>>>>> my
>>>>>>>>>>> views to set content-type? as well.
>>>>>>>>>>>
>>>>>>>>>>> Thanks much,
>>>>>>>>>>>
>>>>>>>>>>> Nitin
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Paul Davis
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Hello all,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>>>>>> finally
>>>>>>>>>>>>> made
>>>>>>>>>>>>> a crack ---
>>>>>>>>>>>>>
>>>>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api
>>>>>>>>>>>>> -
>>>>>>>>>>>>> not
>>>>>>>>>>>>> using
>>>>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>>>>
>>>>>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>>>>>> which
>>>>>>>>>>>>> explains why it's not working - but not a clue how to work
>>>>>>>>>>>>> around
>>>>>>>>>>>>> this.
>>>>>>>>>>>>>
>>>>>>>>>>>>> get query:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>>>>> ?
>>>>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>>>>> query
>>>>>>>>>>>>> key:callback"}
>>>>>>>>>>>>>
>>>>>>>>>>>>> I don't have the option to use either couch.js or
>>>>>>>>>>>>> jquery.couch.js
>>>>>>>>>>>>> but
>>>>>>>>>>>>> have
>>>>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post,
>>>>>>>>>>>>> $,getJSON
>>>>>>>>>>>>> etc.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Nitin
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>>>>> Nitin Borwankar
>>>>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Aug 2, 2009 at 3:26 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Nitin Borwankar wrote:
>>
>> $.get("http://localhost:5984/", function(data){ alert(data.version); },
>> "json" );
>> $.get("http://localhost:5984/", function(data){ alert(data['version']); },
>> "json" );
>>
>> these give an alert that says "undefined".
>>
>> I have just been unable to get the browser to interpret the response from
>> couch as "json".
>
>
> OK, finally success. I set the type to "json" and did a JSON.parse(data) on
> the data passed into the callback.
> It seems strange that this has to be explicitly done. This appears to be a
> content tye issue. I debugged this using curl -v more below.
>
>
> This is what worked
>
> include the script
> <script src="/_utils/script/json2.js"></script>
> amongst others
>
> $.get("http://localhost:5984/", function(data){
> alert(JSON.parse(data)['version']); }, "json" );
>
> this gives an alert with 0.9.0 as expected.
>
> So the major hurdle has been cleared.
>
> Paul many thanks again for your patience.
>
> Here's what I saw using curl -v pointing to just the base url for couchdb
>
> curl -v $CDBA
Try this instead:
curl -v -H 'Accept: application/json' http://127.0.0.1:5984/
Peeping the jquery docs for $.get I don't see a way to set headers
there. Checking the jquery.couch.js it looks like it's doing something
like:
$.ajax({
type: "PUT",
url: this.uri,
contentType: "application/json",
...
});
HTH,
Paul Davis
>
> * About to connect() to localhost port 5984 (#0)
> * Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 5984 (#0)
> * Server auth using Basic with user 'nitin'
>> GET / HTTP/1.1
>> Authorization: Basic bml0aW46bjF0MW4=
>> 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:22:21 GMT
> < Content-Type: text/plain;charset=utf-8 <------------ note couch is
> returning a text/plain rather than application/json
> < Content-Length: 40
> < Cache-Control: must-revalidate
> <
> {"couchdb":"Welcome","version":"0.9.0"}
> * Connection #0 to host localhost left intact
> * Closing connection #0
>
> Not sure if there's a reason for this or this could be legitimately changed
> in 0.10
>
> Nitin
>
>
>
>
>
>
> Nitin
>
>
>
>>
>>
>> Nitin
>>
>>> Paul
>>>
>>>
>>>>
>>>> Nitin
>>>>
>>>>>
>>>>> Then you can just make AJAX call's directly from the page without
>>>>> worrying about the callback parameter at all. This is probably what
>>>>> you want.
>>>>>
>>>>> If not, then you'll need to upgrade.
>>>>>
>>>>> HTH,
>>>>> Paul Davis
>>>>>
>>>>>
>>>>>
>>>>>>>
>>>>>>> HTH,
>>>>>>> Paul Davis
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Paul
>>>>>>>>>
>>>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin
>>>>>>>>> Borwankar<ni...@borwankar.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Ntitn,
>>>>>>>>>>>
>>>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Hey Paul,
>>>>>>>>>>
>>>>>>>>>> Thanks much
>>>>>>>>>>
>>>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>>>
>>>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>>>
>>>>>>>>>> Also assuming the answer is yes - in the new improved couch - do I
>>>>>>>>>> just
>>>>>>>>>> use
>>>>>>>>>> the callback=? on the client request or do I have to do something
>>>>>>>>>> in
>>>>>>>>>> my
>>>>>>>>>> views to set content-type? as well.
>>>>>>>>>>
>>>>>>>>>> Thanks much,
>>>>>>>>>>
>>>>>>>>>> Nitin
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Paul Davis
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Hello all,
>>>>>>>>>>>>
>>>>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>>>>> finally
>>>>>>>>>>>> made
>>>>>>>>>>>> a crack ---
>>>>>>>>>>>>
>>>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api
>>>>>>>>>>>> -
>>>>>>>>>>>> not
>>>>>>>>>>>> using
>>>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>>>
>>>>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>>>>> which
>>>>>>>>>>>> explains why it's not working - but not a clue how to work
>>>>>>>>>>>> around
>>>>>>>>>>>> this.
>>>>>>>>>>>>
>>>>>>>>>>>> get query:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>>>> ?
>>>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>>>> query
>>>>>>>>>>>> key:callback"}
>>>>>>>>>>>>
>>>>>>>>>>>> I don't have the option to use either couch.js or
>>>>>>>>>>>> jquery.couch.js
>>>>>>>>>>>> but
>>>>>>>>>>>> have
>>>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post,
>>>>>>>>>>>> $,getJSON
>>>>>>>>>>>> etc.
>>>>>>>>>>>>
>>>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>>>
>>>>>>>>>>>> Nitin
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>>>> Nitin Borwankar
>>>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Oliver Boermans wrote:
> 2009/8/2 Nitin Borwankar <ni...@borwankar.com>:
>
>> but when the type is "json" and I try alert(data.version) or
>> alert(data['version']) I get "undefined".
>>
>> $.get("http://localhost:5984/", function(data){ alert(data.version); },
>> "json" );
>> $.get("http://localhost:5984/", function(data){ alert(data['version']); },
>> "json" );
>>
>
> Have you tried getJSON?:
> http://docs.jquery.com/Ajax/jQuery.getJSON
>
> Failing that you ought to be able to construct the request you need
> using the more generic jQuery ajax method:
> http://docs.jquery.com/Ajax/jQuery.ajax#options
>
> Sorry I can’t try jsonp here - my couch is broken :/
>
Hi Oliver,
yes I started with that - it's a long story but it comes down to couch
returning content-type text plain in the HTTP response headers,
so an extra JSON.parse() has to be applied to get json.
See my other email.
Many thanks to Paul for his patience. And good luck with your upgrade.
Have you tried CouchDBX - after many travails with 0.8.1 building from
source on the Mac - I just switched to CouchDBX and have been very happy
with it. I do build 0.9.0 from source on Ubuntu.
Nitin
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Oliver Boermans <bo...@gmail.com>.
2009/8/2 Nitin Borwankar <ni...@borwankar.com>:
> but when the type is "json" and I try alert(data.version) or
> alert(data['version']) I get "undefined".
>
> $.get("http://localhost:5984/", function(data){ alert(data.version); },
> "json" );
> $.get("http://localhost:5984/", function(data){ alert(data['version']); },
> "json" );
Have you tried getJSON?:
http://docs.jquery.com/Ajax/jQuery.getJSON
Failing that you ought to be able to construct the request you need
using the more generic jQuery ajax method:
http://docs.jquery.com/Ajax/jQuery.ajax#options
Sorry I can’t try jsonp here - my couch is broken :/
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Nitin Borwankar wrote:
>
> $.get("http://localhost:5984/", function(data){ alert(data.version);
> }, "json" );
> $.get("http://localhost:5984/", function(data){
> alert(data['version']); }, "json" );
>
> these give an alert that says "undefined".
>
> I have just been unable to get the browser to interpret the response
> from couch as "json".
OK, finally success. I set the type to "json" and did a
JSON.parse(data) on the data passed into the callback.
It seems strange that this has to be explicitly done. This appears to
be a content tye issue. I debugged this using curl -v more below.
This is what worked
include the script
<script src="/_utils/script/json2.js"></script>
amongst others
$.get("http://localhost:5984/", function(data){
alert(JSON.parse(data)['version']); }, "json" );
this gives an alert with 0.9.0 as expected.
So the major hurdle has been cleared.
Paul many thanks again for your patience.
Here's what I saw using curl -v pointing to just the base url for couchdb
curl -v $CDBA
* About to connect() to localhost port 5984 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
* Server auth using Basic with user 'nitin'
> GET / HTTP/1.1
> Authorization: Basic bml0aW46bjF0MW4=
> 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:22:21 GMT
< Content-Type: text/plain;charset=utf-8 <------------ note couch
is returning a text/plain rather than application/json
< Content-Length: 40
< Cache-Control: must-revalidate
<
{"couchdb":"Welcome","version":"0.9.0"}
* Connection #0 to host localhost left intact
* Closing connection #0
Not sure if there's a reason for this or this could be legitimately
changed in 0.10
Nitin
Nitin
>
>
> Nitin
>
>> Paul
>>
>>
>>> Nitin
>>>
>>>> Then you can just make AJAX call's directly from the page without
>>>> worrying about the callback parameter at all. This is probably what
>>>> you want.
>>>>
>>>> If not, then you'll need to upgrade.
>>>>
>>>> HTH,
>>>> Paul Davis
>>>>
>>>>
>>>>
>>>>>> HTH,
>>>>>> Paul Davis
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>> Paul
>>>>>>>>
>>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin
>>>>>>>> Borwankar<ni...@borwankar.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Ntitn,
>>>>>>>>>>
>>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> Hey Paul,
>>>>>>>>>
>>>>>>>>> Thanks much
>>>>>>>>>
>>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>>
>>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>>
>>>>>>>>> Also assuming the answer is yes - in the new improved couch -
>>>>>>>>> do I
>>>>>>>>> just
>>>>>>>>> use
>>>>>>>>> the callback=? on the client request or do I have to do
>>>>>>>>> something in
>>>>>>>>> my
>>>>>>>>> views to set content-type? as well.
>>>>>>>>>
>>>>>>>>> Thanks much,
>>>>>>>>>
>>>>>>>>> Nitin
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Paul Davis
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar
>>>>>>>>>> <ni...@borwankar.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Hello all,
>>>>>>>>>>>
>>>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>>>> finally
>>>>>>>>>>> made
>>>>>>>>>>> a crack ---
>>>>>>>>>>>
>>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb
>>>>>>>>>>> api -
>>>>>>>>>>> not
>>>>>>>>>>> using
>>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>>
>>>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>>>> which
>>>>>>>>>>> explains why it's not working - but not a clue how to work
>>>>>>>>>>> around
>>>>>>>>>>> this.
>>>>>>>>>>>
>>>>>>>>>>> get query:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>>>
>>>>>>>>>>> ?
>>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>>> query
>>>>>>>>>>> key:callback"}
>>>>>>>>>>>
>>>>>>>>>>> I don't have the option to use either couch.js or
>>>>>>>>>>> jquery.couch.js
>>>>>>>>>>> but
>>>>>>>>>>> have
>>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post,
>>>>>>>>>>> $,getJSON
>>>>>>>>>>> etc.
>>>>>>>>>>>
>>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>>
>>>>>>>>>>> Nitin
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>>>
>>>>>>>>>>> Nitin Borwankar
>>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Davis wrote:
>> b) this is what I was doing before I tried to make it work with the file://
>> But not using a callback=? param and using the following url - just to see
>> if I can get any json at all -
>>
>> $.get("http://localhost:5984/", function(data){ alert(data); } );
>>
>> gives me an alert with nothing in it.
>>
>>
>
> Where are you loading this code from? Is it in an attachment on a doc
> in CouchDB? Can you perhaps make a simple HTML doc with some AJAX in
> it and try loading that from CouchDB to see what happens?
>
>
yes it is is in an html doc and is under _attachments
I invoke it via the url
http://localhost:5984/ptest2/_design/vt2/index_1.html
I made some progress - I added a type param "text" after the function
$.get("http://localhost:5984/", function(data){ alert(data); }, "text" );
and I do get the json as a string in the alert.
but when the type is "json" and I try alert(data.version) or
alert(data['version']) I get "undefined".
$.get("http://localhost:5984/", function(data){ alert(data.version); }, "json" );
$.get("http://localhost:5984/", function(data){ alert(data['version']); }, "json" );
these give an alert that says "undefined".
I have just been unable to get the browser to interpret the response
from couch as "json".
Nitin
> Paul
>
>
>> Nitin
>>
>>> Then you can just make AJAX call's directly from the page without
>>> worrying about the callback parameter at all. This is probably what
>>> you want.
>>>
>>> If not, then you'll need to upgrade.
>>>
>>> HTH,
>>> Paul Davis
>>>
>>>
>>>
>>>>> HTH,
>>>>> Paul Davis
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>> Paul
>>>>>>>
>>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Paul Joseph Davis wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Ntitn,
>>>>>>>>>
>>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Hey Paul,
>>>>>>>>
>>>>>>>> Thanks much
>>>>>>>>
>>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>>
>>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>>
>>>>>>>> Also assuming the answer is yes - in the new improved couch - do I
>>>>>>>> just
>>>>>>>> use
>>>>>>>> the callback=? on the client request or do I have to do something in
>>>>>>>> my
>>>>>>>> views to set content-type? as well.
>>>>>>>>
>>>>>>>> Thanks much,
>>>>>>>>
>>>>>>>> Nitin
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Paul Davis
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hello all,
>>>>>>>>>>
>>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>>> finally
>>>>>>>>>> made
>>>>>>>>>> a crack ---
>>>>>>>>>>
>>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
>>>>>>>>>> not
>>>>>>>>>> using
>>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>>
>>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>>> which
>>>>>>>>>> explains why it's not working - but not a clue how to work around
>>>>>>>>>> this.
>>>>>>>>>>
>>>>>>>>>> get query:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>>> ?
>>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>>> query
>>>>>>>>>> key:callback"}
>>>>>>>>>>
>>>>>>>>>> I don't have the option to use either couch.js or jquery.couch.js
>>>>>>>>>> but
>>>>>>>>>> have
>>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON
>>>>>>>>>> etc.
>>>>>>>>>>
>>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>>
>>>>>>>>>> Nitin
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>>> Nitin Borwankar
>>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Aug 2, 2009 at 2:01 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Davis wrote:
>>
>> On Sun, Aug 2, 2009 at 12:36 AM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>>
>>>
>>> Paul Davis wrote:
>>>
>>>>
>>>> On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<ni...@borwankar.com>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Paul Davis wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Nitin,
>>>>>>
>>>>>> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
>>>>>> have to either wait for 0.10.0 or ride trunk to get JSONP.
>>>>>>
>>>>>> There's nothing with content-type to worry about. The only thing I'm
>>>>>> not sure of is if we fixed the _ parameter rejection or not. If not
>>>>>> you can just add ignore=true to JSONP requests.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> So for now if I want to make couch REST calls via javascript in the
>>>>> browser
>>>>> - I use couch.js ? jquery.couch.js ?
>>>>>
>>>>> Nitin
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> JSONP is only required for cross domain requests. If you're using
>>>> CouchApps then you can just call to the hosting URL of interest using
>>>> normal jquery calls. If you do need the cross domain requests then
>>>> there really isn't anything that can be done for 0.9 other than
>>>> writing a proxy or overcoming the limitations with a proxy or some
>>>> other approach.
>>>>
>>>>
>>>>
>>>
>>> Hi Paul,
>>>
>>> Thanks again for sticking with me on this -
>>>
>>> ok, so right now everything is on my laptop - client server everything.
>>> I have couchdbx, I am testing from a file:// url with safari and FF3.5
>>>
>>> I have a file with html, jquery and a $.ajax() call to
>>> localhost:5984/........./ parm=val&parm=val&parm=val&callback=?
>>> I get an error from couch complaining about a bad param ie. the
>>> callback=?
>>>
>>> Here's the jQuery code
>>>
>>>
>>> $(document).ready(function() {
>>> alert("indoc");
>>>
>>> $.ajax({
>>> //url:
>>> "http://twitter.com/status/user_timeline/nitin.json?count=10&callback=?",
>>> // the above twitter url works an returns valid json
>>>
>>> url:
>>>
>>> "http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=?",
>>> type: "GET",
>>> dataType: "json",
>>> success: function(msg){
>>> alert(msg);
>>> },
>>> error: function(msg){
>>> alert('failed to get json');
>>> }
>>> });
>>>
>>> alert('after $.ajax');
>>> });
>>>
>>> The failed alert comes up.
>>>
>>> I tried the url in a browser, here's what I got
>>>
>>> {"error":"query_parse_error","reason":"Bad URL query
>>> key:callback"}
>>>
>>>
>>> This is all I need to get working - so is this "cross domain ?" I'm not
>>> sure. Once this works I can get this stuff working inside a couchapp
>>> but
>>> for now I need to make it work with a jQuery request just so I understand
>>> what's going on, stripped to the bare essentials.
>>>
>>> If couch complains about the extra callback param I am not sure this is a
>>> cross-domain issue - but I don't understand the nuance of that issue well
>>> enough.
>>>
>>> Any help to get me over this hump much appreciated - I am already 2-3
>>> days
>>> of straight head banging trying to get beyond this.
>>>
>>> Nitin
>>>
>>>
>>
>> Cross domain refers to where your code is loading from. If you're
>> loading from file:// my guess is that this won't work properly. If you
>> put it in a CouchApp to test so that you're loading from a URL like:
>>
>> http://127.0.0.1:5984/db_name/_design/foo/_attachments/my.html
>>
>
> Two questions.
>
> a) there's no '_attachments' in the URL is there ? - it's working for me
> without the _attachments but not with.
Duh. Yeah, my bad.
>
> b) this is what I was doing before I tried to make it work with the file://
> But not using a callback=? param and using the following url - just to see
> if I can get any json at all -
>
> $.get("http://localhost:5984/", function(data){ alert(data); } );
>
> gives me an alert with nothing in it.
>
Where are you loading this code from? Is it in an attachment on a doc
in CouchDB? Can you perhaps make a simple HTML doc with some AJAX in
it and try loading that from CouchDB to see what happens?
Paul
> Nitin
>>
>> Then you can just make AJAX call's directly from the page without
>> worrying about the callback parameter at all. This is probably what
>> you want.
>>
>> If not, then you'll need to upgrade.
>>
>> HTH,
>> Paul Davis
>>
>>
>>>>
>>>> HTH,
>>>> Paul Davis
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Paul
>>>>>>
>>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Paul Joseph Davis wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Ntitn,
>>>>>>>>
>>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> Hey Paul,
>>>>>>>
>>>>>>> Thanks much
>>>>>>>
>>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>>
>>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>>
>>>>>>> Also assuming the answer is yes - in the new improved couch - do I
>>>>>>> just
>>>>>>> use
>>>>>>> the callback=? on the client request or do I have to do something in
>>>>>>> my
>>>>>>> views to set content-type? as well.
>>>>>>>
>>>>>>> Thanks much,
>>>>>>>
>>>>>>> Nitin
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Paul Davis
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hello all,
>>>>>>>>>
>>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>>> finally
>>>>>>>>> made
>>>>>>>>> a crack ---
>>>>>>>>>
>>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
>>>>>>>>> not
>>>>>>>>> using
>>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>>> Couldn't get a successful response.
>>>>>>>>>
>>>>>>>>> finally just put the get query into firefx and go the following
>>>>>>>>> which
>>>>>>>>> explains why it's not working - but not a clue how to work around
>>>>>>>>> this.
>>>>>>>>>
>>>>>>>>> get query:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>>> ?
>>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL
>>>>>>>>> query
>>>>>>>>> key:callback"}
>>>>>>>>>
>>>>>>>>> I don't have the option to use either couch.js or jquery.couch.js
>>>>>>>>> but
>>>>>>>>> have
>>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON
>>>>>>>>> etc.
>>>>>>>>>
>>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>>
>>>>>>>>> Nitin
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>>> Nitin Borwankar
>>>>>>>>> nborwankar@gmail.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Davis wrote:
> On Sun, Aug 2, 2009 at 12:36 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
>
>> Paul Davis wrote:
>>
>>> On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<ni...@borwankar.com>
>>> wrote:
>>>
>>>
>>>> Paul Davis wrote:
>>>>
>>>>
>>>>> Nitin,
>>>>>
>>>>> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
>>>>> have to either wait for 0.10.0 or ride trunk to get JSONP.
>>>>>
>>>>> There's nothing with content-type to worry about. The only thing I'm
>>>>> not sure of is if we fixed the _ parameter rejection or not. If not
>>>>> you can just add ignore=true to JSONP requests.
>>>>>
>>>>>
>>>>>
>>>>>
>>>> So for now if I want to make couch REST calls via javascript in the
>>>> browser
>>>> - I use couch.js ? jquery.couch.js ?
>>>>
>>>> Nitin
>>>>
>>>>
>>>>
>>>>
>>> JSONP is only required for cross domain requests. If you're using
>>> CouchApps then you can just call to the hosting URL of interest using
>>> normal jquery calls. If you do need the cross domain requests then
>>> there really isn't anything that can be done for 0.9 other than
>>> writing a proxy or overcoming the limitations with a proxy or some
>>> other approach.
>>>
>>>
>>>
>> Hi Paul,
>>
>> Thanks again for sticking with me on this -
>>
>> ok, so right now everything is on my laptop - client server everything.
>> I have couchdbx, I am testing from a file:// url with safari and FF3.5
>>
>> I have a file with html, jquery and a $.ajax() call to
>> localhost:5984/........./ parm=val&parm=val&parm=val&callback=?
>> I get an error from couch complaining about a bad param ie. the callback=?
>>
>> Here's the jQuery code
>>
>>
>> $(document).ready(function() {
>> alert("indoc");
>>
>> $.ajax({
>> //url:
>> "http://twitter.com/status/user_timeline/nitin.json?count=10&callback=?",
>> // the above twitter url works an returns valid json
>>
>> url:
>> "http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=?",
>> type: "GET",
>> dataType: "json",
>> success: function(msg){
>> alert(msg);
>> },
>> error: function(msg){
>> alert('failed to get json');
>> }
>> });
>>
>> alert('after $.ajax');
>> });
>>
>> The failed alert comes up.
>>
>> I tried the url in a browser, here's what I got
>>
>> {"error":"query_parse_error","reason":"Bad URL query
>> key:callback"}
>>
>>
>> This is all I need to get working - so is this "cross domain ?" I'm not
>> sure. Once this works I can get this stuff working inside a couchapp but
>> for now I need to make it work with a jQuery request just so I understand
>> what's going on, stripped to the bare essentials.
>>
>> If couch complains about the extra callback param I am not sure this is a
>> cross-domain issue - but I don't understand the nuance of that issue well
>> enough.
>>
>> Any help to get me over this hump much appreciated - I am already 2-3 days
>> of straight head banging trying to get beyond this.
>>
>> Nitin
>>
>>
>
> Cross domain refers to where your code is loading from. If you're
> loading from file:// my guess is that this won't work properly. If you
> put it in a CouchApp to test so that you're loading from a URL like:
>
> http://127.0.0.1:5984/db_name/_design/foo/_attachments/my.html
>
Two questions.
a) there's no '_attachments' in the URL is there ? - it's working for
me without the _attachments but not with.
b) this is what I was doing before I tried to make it work with the file://
But not using a callback=? param and using the following url - just to
see if I can get any json at all -
$.get("http://localhost:5984/", function(data){ alert(data); } );
gives me an alert with nothing in it.
Nitin
> Then you can just make AJAX call's directly from the page without
> worrying about the callback parameter at all. This is probably what
> you want.
>
> If not, then you'll need to upgrade.
>
> HTH,
> Paul Davis
>
>
>>> HTH,
>>> Paul Davis
>>>
>>>
>>>
>>>>
>>>>> Paul
>>>>>
>>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Paul Joseph Davis wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Ntitn,
>>>>>>>
>>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Hey Paul,
>>>>>>
>>>>>> Thanks much
>>>>>>
>>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>>
>>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>>
>>>>>> Also assuming the answer is yes - in the new improved couch - do I just
>>>>>> use
>>>>>> the callback=? on the client request or do I have to do something in my
>>>>>> views to set content-type? as well.
>>>>>>
>>>>>> Thanks much,
>>>>>>
>>>>>> Nitin
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Paul Davis
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>>> finally
>>>>>>>> made
>>>>>>>> a crack ---
>>>>>>>>
>>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
>>>>>>>> not
>>>>>>>> using
>>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>>> Couldn't get a successful response.
>>>>>>>>
>>>>>>>> finally just put the get query into firefx and go the following which
>>>>>>>> explains why it's not working - but not a clue how to work around
>>>>>>>> this.
>>>>>>>>
>>>>>>>> get query:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>>> ?
>>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>>>>>>> key:callback"}
>>>>>>>>
>>>>>>>> I don't have the option to use either couch.js or jquery.couch.js but
>>>>>>>> have
>>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON
>>>>>>>> etc.
>>>>>>>>
>>>>>>>> Am I stuck without any help possible ?
>>>>>>>>
>>>>>>>> Nitin
>>>>>>>>
>>>>>>>>
>>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> -------------------------------------------------------------------------------------
>>>>>>>> Nitin Borwankar
>>>>>>>> nborwankar@gmail.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Aug 2, 2009 at 12:36 AM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Davis wrote:
>>
>> On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>>
>>>
>>> Paul Davis wrote:
>>>
>>>>
>>>> Nitin,
>>>>
>>>> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
>>>> have to either wait for 0.10.0 or ride trunk to get JSONP.
>>>>
>>>> There's nothing with content-type to worry about. The only thing I'm
>>>> not sure of is if we fixed the _ parameter rejection or not. If not
>>>> you can just add ignore=true to JSONP requests.
>>>>
>>>>
>>>>
>>>
>>> So for now if I want to make couch REST calls via javascript in the
>>> browser
>>> - I use couch.js ? jquery.couch.js ?
>>>
>>> Nitin
>>>
>>>
>>>
>>
>> JSONP is only required for cross domain requests. If you're using
>> CouchApps then you can just call to the hosting URL of interest using
>> normal jquery calls. If you do need the cross domain requests then
>> there really isn't anything that can be done for 0.9 other than
>> writing a proxy or overcoming the limitations with a proxy or some
>> other approach.
>>
>>
>
> Hi Paul,
>
> Thanks again for sticking with me on this -
>
> ok, so right now everything is on my laptop - client server everything.
> I have couchdbx, I am testing from a file:// url with safari and FF3.5
>
> I have a file with html, jquery and a $.ajax() call to
> localhost:5984/........./ parm=val&parm=val&parm=val&callback=?
> I get an error from couch complaining about a bad param ie. the callback=?
>
> Here's the jQuery code
>
>
> $(document).ready(function() {
> alert("indoc");
>
> $.ajax({
> //url:
> "http://twitter.com/status/user_timeline/nitin.json?count=10&callback=?",
> // the above twitter url works an returns valid json
>
> url:
> "http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=?",
> type: "GET",
> dataType: "json",
> success: function(msg){
> alert(msg);
> },
> error: function(msg){
> alert('failed to get json');
> }
> });
>
> alert('after $.ajax');
> });
>
> The failed alert comes up.
>
> I tried the url in a browser, here's what I got
>
> {"error":"query_parse_error","reason":"Bad URL query
> key:callback"}
>
>
> This is all I need to get working - so is this "cross domain ?" I'm not
> sure. Once this works I can get this stuff working inside a couchapp but
> for now I need to make it work with a jQuery request just so I understand
> what's going on, stripped to the bare essentials.
>
> If couch complains about the extra callback param I am not sure this is a
> cross-domain issue - but I don't understand the nuance of that issue well
> enough.
>
> Any help to get me over this hump much appreciated - I am already 2-3 days
> of straight head banging trying to get beyond this.
>
> Nitin
>
Cross domain refers to where your code is loading from. If you're
loading from file:// my guess is that this won't work properly. If you
put it in a CouchApp to test so that you're loading from a URL like:
http://127.0.0.1:5984/db_name/_design/foo/_attachments/my.html
Then you can just make AJAX call's directly from the page without
worrying about the callback parameter at all. This is probably what
you want.
If not, then you'll need to upgrade.
HTH,
Paul Davis
>
>> HTH,
>> Paul Davis
>>
>>
>>>
>>>
>>>>
>>>> Paul
>>>>
>>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Paul Joseph Davis wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Ntitn,
>>>>>>
>>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>>
>>>>>>
>>>>>
>>>>> Hey Paul,
>>>>>
>>>>> Thanks much
>>>>>
>>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>>
>>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>>
>>>>> Also assuming the answer is yes - in the new improved couch - do I just
>>>>> use
>>>>> the callback=? on the client request or do I have to do something in my
>>>>> views to set content-type? as well.
>>>>>
>>>>> Thanks much,
>>>>>
>>>>> Nitin
>>>>>
>>>>>
>>>>>>
>>>>>> Paul Davis
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Hello all,
>>>>>>>
>>>>>>> I have been banging my head against this wall for 2 days and I
>>>>>>> finally
>>>>>>> made
>>>>>>> a crack ---
>>>>>>>
>>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
>>>>>>> not
>>>>>>> using
>>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>>> Couldn't get a successful response.
>>>>>>>
>>>>>>> finally just put the get query into firefx and go the following which
>>>>>>> explains why it's not working - but not a clue how to work around
>>>>>>> this.
>>>>>>>
>>>>>>> get query:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>>> ?
>>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>>>>>> key:callback"}
>>>>>>>
>>>>>>> I don't have the option to use either couch.js or jquery.couch.js but
>>>>>>> have
>>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON
>>>>>>> etc.
>>>>>>>
>>>>>>> Am I stuck without any help possible ?
>>>>>>>
>>>>>>> Nitin
>>>>>>>
>>>>>>>
>>>>>>> 37% of all statistics are made up on the spot
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -------------------------------------------------------------------------------------
>>>>>>> Nitin Borwankar
>>>>>>> nborwankar@gmail.com
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Davis wrote:
> On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
>
>> Paul Davis wrote:
>>
>>> Nitin,
>>>
>>> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
>>> have to either wait for 0.10.0 or ride trunk to get JSONP.
>>>
>>> There's nothing with content-type to worry about. The only thing I'm
>>> not sure of is if we fixed the _ parameter rejection or not. If not
>>> you can just add ignore=true to JSONP requests.
>>>
>>>
>>>
>> So for now if I want to make couch REST calls via javascript in the browser
>> - I use couch.js ? jquery.couch.js ?
>>
>> Nitin
>>
>>
>>
>
> JSONP is only required for cross domain requests. If you're using
> CouchApps then you can just call to the hosting URL of interest using
> normal jquery calls. If you do need the cross domain requests then
> there really isn't anything that can be done for 0.9 other than
> writing a proxy or overcoming the limitations with a proxy or some
> other approach.
>
>
Hi Paul,
Thanks again for sticking with me on this -
ok, so right now everything is on my laptop - client server everything.
I have couchdbx, I am testing from a file:// url with safari and FF3.5
I have a file with html, jquery and a $.ajax() call to
localhost:5984/........./ parm=val&parm=val&parm=val&callback=?
I get an error from couch complaining about a bad param ie. the callback=?
Here's the jQuery code
$(document).ready(function() {
alert("indoc");
$.ajax({
//url:
"http://twitter.com/status/user_timeline/nitin.json?count=10&callback=?",
// the above twitter url works an returns valid json
url:
"http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=?",
type: "GET",
dataType: "json",
success: function(msg){
alert(msg);
},
error: function(msg){
alert('failed to get json');
}
});
alert('after $.ajax');
});
The failed alert comes up.
I tried the url in a browser, here's what I got
{"error":"query_parse_error","reason":"Bad URL query
key:callback"}
This is all I need to get working - so is this "cross domain ?" I'm not
sure. Once this works I can get this stuff working inside a couchapp
but for now I need to make it work with a jQuery request just so I
understand what's going on, stripped to the bare essentials.
If couch complains about the extra callback param I am not sure this is
a cross-domain issue - but I don't understand the nuance of that issue
well enough.
Any help to get me over this hump much appreciated - I am already 2-3
days of straight head banging trying to get beyond this.
Nitin
> HTH,
> Paul Davis
>
>
>>
>>> Paul
>>>
>>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>>> wrote:
>>>
>>>
>>>> Paul Joseph Davis wrote:
>>>>
>>>>
>>>>> Ntitn,
>>>>>
>>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>>
>>>>>
>>>> Hey Paul,
>>>>
>>>> Thanks much
>>>>
>>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>>
>>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>>
>>>> Also assuming the answer is yes - in the new improved couch - do I just
>>>> use
>>>> the callback=? on the client request or do I have to do something in my
>>>> views to set content-type? as well.
>>>>
>>>> Thanks much,
>>>>
>>>> Nitin
>>>>
>>>>
>>>>> Paul Davis
>>>>>
>>>>>
>>>>>
>>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I have been banging my head against this wall for 2 days and I finally
>>>>>> made
>>>>>> a crack ---
>>>>>>
>>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api - not
>>>>>> using
>>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>>> Couldn't get a successful response.
>>>>>>
>>>>>> finally just put the get query into firefx and go the following which
>>>>>> explains why it's not working - but not a clue how to work around this.
>>>>>>
>>>>>> get query:
>>>>>>
>>>>>>
>>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>>> ?
>>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>>>>> key:callback"}
>>>>>>
>>>>>> I don't have the option to use either couch.js or jquery.couch.js but
>>>>>> have
>>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>>>>>>
>>>>>> Am I stuck without any help possible ?
>>>>>>
>>>>>> Nitin
>>>>>>
>>>>>>
>>>>>> 37% of all statistics are made up on the spot
>>>>>>
>>>>>>
>>>>>> -------------------------------------------------------------------------------------
>>>>>> Nitin Borwankar
>>>>>> nborwankar@gmail.com
>>>>>>
>>>>>>
>>>>
>>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Davis wrote:
>>
>> Nitin,
>>
>> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
>> have to either wait for 0.10.0 or ride trunk to get JSONP.
>>
>> There's nothing with content-type to worry about. The only thing I'm
>> not sure of is if we fixed the _ parameter rejection or not. If not
>> you can just add ignore=true to JSONP requests.
>>
>>
>
> So for now if I want to make couch REST calls via javascript in the browser
> - I use couch.js ? jquery.couch.js ?
>
> Nitin
>
>
JSONP is only required for cross domain requests. If you're using
CouchApps then you can just call to the hosting URL of interest using
normal jquery calls. If you do need the cross domain requests then
there really isn't anything that can be done for 0.9 other than
writing a proxy or overcoming the limitations with a proxy or some
other approach.
HTH,
Paul Davis
>
>
>> Paul
>>
>> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>>
>>>
>>> Paul Joseph Davis wrote:
>>>
>>>>
>>>> Ntitn,
>>>>
>>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>>
>>>
>>> Hey Paul,
>>>
>>> Thanks much
>>>
>>> I am on couchdbx 0.9 on leopard 10.5.7
>>>
>>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>>
>>> Also assuming the answer is yes - in the new improved couch - do I just
>>> use
>>> the callback=? on the client request or do I have to do something in my
>>> views to set content-type? as well.
>>>
>>> Thanks much,
>>>
>>> Nitin
>>>
>>>>
>>>> Paul Davis
>>>>
>>>>
>>>>
>>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
>>>>
>>>>
>>>>>
>>>>> Hello all,
>>>>>
>>>>> I have been banging my head against this wall for 2 days and I finally
>>>>> made
>>>>> a crack ---
>>>>>
>>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api - not
>>>>> using
>>>>> ( cannot use ) couchapp must call from legacy app.
>>>>> Couldn't get a successful response.
>>>>>
>>>>> finally just put the get query into firefx and go the following which
>>>>> explains why it's not working - but not a clue how to work around this.
>>>>>
>>>>> get query:
>>>>>
>>>>>
>>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>>> ?
>>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>>>> key:callback"}
>>>>>
>>>>> I don't have the option to use either couch.js or jquery.couch.js but
>>>>> have
>>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>>>>>
>>>>> Am I stuck without any help possible ?
>>>>>
>>>>> Nitin
>>>>>
>>>>>
>>>>> 37% of all statistics are made up on the spot
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------------------------
>>>>> Nitin Borwankar
>>>>> nborwankar@gmail.com
>>>>>
>>>
>>>
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Davis wrote:
> Nitin,
>
> Its not 0.9.1 either, the minor versions are bug fixes only. You'll
> have to either wait for 0.10.0 or ride trunk to get JSONP.
>
> There's nothing with content-type to worry about. The only thing I'm
> not sure of is if we fixed the _ parameter rejection or not. If not
> you can just add ignore=true to JSONP requests.
>
>
So for now if I want to make couch REST calls via javascript in the
browser - I use couch.js ? jquery.couch.js ?
Nitin
> Paul
>
> On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
>
>> Paul Joseph Davis wrote:
>>
>>> Ntitn,
>>>
>>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>>>
>> Hey Paul,
>>
>> Thanks much
>>
>> I am on couchdbx 0.9 on leopard 10.5.7
>>
>> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>>
>> Also assuming the answer is yes - in the new improved couch - do I just use
>> the callback=? on the client request or do I have to do something in my
>> views to set content-type? as well.
>>
>> Thanks much,
>>
>> Nitin
>>
>>> Paul Davis
>>>
>>>
>>>
>>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
>>>
>>>
>>>> Hello all,
>>>>
>>>> I have been banging my head against this wall for 2 days and I finally
>>>> made
>>>> a crack ---
>>>>
>>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api - not
>>>> using
>>>> ( cannot use ) couchapp must call from legacy app.
>>>> Couldn't get a successful response.
>>>>
>>>> finally just put the get query into firefx and go the following which
>>>> explains why it's not working - but not a clue how to work around this.
>>>>
>>>> get query:
>>>>
>>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>>> ?
>>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>>> key:callback"}
>>>>
>>>> I don't have the option to use either couch.js or jquery.couch.js but
>>>> have
>>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>>>>
>>>> Am I stuck without any help possible ?
>>>>
>>>> Nitin
>>>>
>>>>
>>>> 37% of all statistics are made up on the spot
>>>>
>>>> -------------------------------------------------------------------------------------
>>>> Nitin Borwankar
>>>> nborwankar@gmail.com
>>>>
>>
Re: callback=? parameter expected by jQuery $.ajax() causes couch to
complain about bad URL
Posted by Paul Davis <pa...@gmail.com>.
Nitin,
Its not 0.9.1 either, the minor versions are bug fixes only. You'll
have to either wait for 0.10.0 or ride trunk to get JSONP.
There's nothing with content-type to worry about. The only thing I'm
not sure of is if we fixed the _ parameter rejection or not. If not
you can just add ignore=true to JSONP requests.
Paul
On Sat, Aug 1, 2009 at 10:43 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Paul Joseph Davis wrote:
>>
>> Ntitn,
>>
>> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
>
> Hey Paul,
>
> Thanks much
>
> I am on couchdbx 0.9 on leopard 10.5.7
>
> Is jsonp in 0.9.1 ? That would be motivation for me to move.
>
> Also assuming the answer is yes - in the new improved couch - do I just use
> the callback=? on the client request or do I have to do something in my
> views to set content-type? as well.
>
> Thanks much,
>
> Nitin
>>
>> Paul Davis
>>
>>
>>
>> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
>>
>>> Hello all,
>>>
>>> I have been banging my head against this wall for 2 days and I finally
>>> made
>>> a crack ---
>>>
>>> Trying to use jQuery, $.ajax() in an app that calls couchdb api - not
>>> using
>>> ( cannot use ) couchapp must call from legacy app.
>>> Couldn't get a successful response.
>>>
>>> finally just put the get query into firefx and go the following which
>>> explains why it's not working - but not a clue how to work around this.
>>>
>>> get query:
>>>
>>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>> ?
>>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>>> key:callback"}
>>>
>>> I don't have the option to use either couch.js or jquery.couch.js but
>>> have
>>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>>>
>>> Am I stuck without any help possible ?
>>>
>>> Nitin
>>>
>>>
>>> 37% of all statistics are made up on the spot
>>>
>>> -------------------------------------------------------------------------------------
>>> Nitin Borwankar
>>> nborwankar@gmail.com
>
>
Re: callback=? parameter expected by jQuery $.ajax() causes couch
to complain about bad URL
Posted by Nitin Borwankar <ni...@borwankar.com>.
Paul Joseph Davis wrote:
> Ntitn,
>
> Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
Hey Paul,
Thanks much
I am on couchdbx 0.9 on leopard 10.5.7
Is jsonp in 0.9.1 ? That would be motivation for me to move.
Also assuming the answer is yes - in the new improved couch - do I just
use the callback=? on the client request or do I have to do something in
my views to set content-type? as well.
Thanks much,
Nitin
>
> Paul Davis
>
>
>
> On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
>
>> Hello all,
>>
>> I have been banging my head against this wall for 2 days and I
>> finally made
>> a crack ---
>>
>> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
>> not using
>> ( cannot use ) couchapp must call from legacy app.
>> Couldn't get a successful response.
>>
>> finally just put the get query into firefx and go the following which
>> explains why it's not working - but not a clue how to work around this.
>>
>> get query:
>> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
>>
>> ?
>> couch responds: {"error":"query_parse_error","reason":"Bad URL query
>> key:callback"}
>>
>> I don't have the option to use either couch.js or jquery.couch.js but
>> have
>> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>>
>> Am I stuck without any help possible ?
>>
>> Nitin
>>
>>
>> 37% of all statistics are made up on the spot
>> -------------------------------------------------------------------------------------
>>
>> Nitin Borwankar
>> nborwankar@gmail.com
Re: callback=? parameter expected by jQuery $.ajax() causes couch to complain about bad URL
Posted by Paul Joseph Davis <pa...@gmail.com>.
Ntitn,
Are you on couchdb trunk? Pretty sure jsonp was after 0.9.
Paul Davis
On Aug 1, 2009, at 9:57 PM, Nitin Borwankar <ni...@borwankar.com> wrote:
> Hello all,
>
> I have been banging my head against this wall for 2 days and I
> finally made
> a crack ---
>
> Trying to use jQuery, $.ajax() in an app that calls couchdb api -
> not using
> ( cannot use ) couchapp must call from legacy app.
> Couldn't get a successful response.
>
> finally just put the get query into firefx and go the following which
> explains why it's not working - but not a clue how to work around
> this.
>
> get query:
> http://localhost:5984/ptest2/_design/vt2/_view/tag?group=true&limit=5&callback=
> ?
> couch responds: {"error":"query_parse_error","reason":"Bad URL query
> key:callback"}
>
> I don't have the option to use either couch.js or jquery.couch.js
> but have
> to use vanilla jQuery ajax calls $.get, $.ajax, $.post, $,getJSON etc.
>
> Am I stuck without any help possible ?
>
> Nitin
>
>
> 37% of all statistics are made up on the spot
> ---
> ---
> ---
> ---
> ---
> ----------------------------------------------------------------------
> Nitin Borwankar
> nborwankar@gmail.com