incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON
Date Sat, 16 Apr 2011 20:40:46 GMT
Good find! :)

Fixed in trunk:

http://svn.apache.org/viewvc?revision=1094049&view=revision

Cheers
Jan
-- 

On 16 Apr 2011, at 21:05, Hendrik Jan van Meerveld wrote:

> Hi Jan,
> 
> Thank you for the reply.
> It seems that the list function does not accept any ajax options.
> 
> The code for list in jquery.couch.js is:
> 
>        list: function(list, view, options) {
>          var list = list.split('/');
>          var options = options || {};
>          var type = 'GET';
>          var data = null;
>          if (options['keys']) {
>            type = 'POST';
>            var keys = options['keys'];
>            delete options['keys'];
>            data = toJSON({'keys': keys });
>          }
>          ajax({
>              type: type,
>              data: data,
>              url: this.uri + '_design/' + list[0] +
>                   '/_list/' + list[1] + '/' + view + encodeOptions(options)
>              },
>              options, 'An error occured accessing the list'
>          );
>        },
> 
> and it seems to me that the options are added to the Url and are not mixed
> in with the ajax options.
> 
> Is this probably a bug or missing feature in jquery.couch?
> Would it be useful when I report it as such?
> 
> For now I'll use $.ajax to get the list.
> 
> Kind regards,
> Hendrik Jan
> 
> On 16 April 2011 19:29, Jan Lehnardt <jan@apache.org> wrote:
> 
>> Hi Hendrick Jan,
>> 
>> On 16 Apr 2011, at 18:36, Hendrik Jan van Meerveld wrote:
>> 
>>> Hi all,
>>> 
>>> I'm trying to place a list on a website.
>>> The list "design/_list/listname/viewname" works fine and gives me the
>> HTML I
>>> want.
>>> 
>>> But if I try to put this HTML on my website like this:
>>>   $db.list("design/listname","viewname",
>>>     {
>>>       success: function(data){
>>>         $("#sometable tbody").append(data);
>>>       }
>>>     }
>>>   );
>>> 
>>> I get the error:
>>> [object XMLHttpRequest] 200: Invalid JSON: <tr id="row_bo......
>> 
>> This looks like jQuery is trying to parse the HTML response as JSON. I
>> believe there are options to turn this off.
>> 
>> Cheers
>> Jan
>> --
>> 
>>> 
>>> So why is my browser trying to read this as JSON?
>>> Does anybody have experience with putting lists on a webpage?
>>> 
>>> Kind regards,
>>> Hendrik Jan
>> 
>> 


Mime
View raw message