couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nitin Borwankar <ni...@borwankar.com>
Subject Re: callback=? parameter expected by jQuery $.ajax() causes couch to complain about bad URL
Date Sun, 02 Aug 2009 04:36:25 GMT
Paul Davis wrote:
> On Sat, Aug 1, 2009 at 11:42 PM, Nitin Borwankar<nitin@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<nitin@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 <nitin@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
>>>>>>
>>>>>>             
>>>>         
>>     


Mime
View raw message