You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Hendrik Jan van Meerveld <ha...@gmail.com> on 2011/04/16 18:36:28 UTC
$.couch.db(dbname).list("dbname/listname","viewname") --> 200:
Invalid JSON
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......
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
Re: $.couch.db(dbname).list(
Posted by Joël Guillod <jo...@me.com>.
… a fix is also needed in file jquery.couchdb.js when a returned data type
is anything other than "json" (e.g. like "html" for a list/show) query:
1036 complete: function(req) {
1037 try {
1038 var resp = httpData(req, "json");
1039 } catch(e) {
line 1038 SHOULD be :
1038 var resp = httpData(req, ajaxOptions.dataType || "json");
Now, it works on my side!
Cheers
Joel
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON
Posted by Joël Guillod <jo...@me.com>.
>> Fixed in trunk:
>>
>> http://svn.apache.org/viewvc?revision=1094049&view=revision
>>
>> Cheers
>> Jan
There is a wrong arguments order for the ajax call inside the list() function
of the jquery.couch.js file:
The last fixed version shows this:
829 list: function(list, view, options, ajaxOptions) {
830 var list = list.split('/');
831 var options = options || {};
832 var type = 'GET';
833 var data = null;
834 if (options['keys']) {
835 type = 'POST';
836 var keys = options['keys'];
837 delete options['keys'];
838 data = toJSON({'keys': keys });
839 }
840 ajax({
841 type: type,
842 data: data,
843 url: this.uri + '_design/' + list[0] +
844 '/_list/' + list[1] + '/' + view + encodeOptions(options)
845 },
846 ajaxOptions, 'An error occured accessing the list'
847 );
848 },
BUT line 846 should be:
'An error occured accessing the list', ajaxOptions
according to the ajax() signature at line 1023 which is:
1023 function ajax(obj, options, errorMessage, ajaxOptions) {
Hope this helps!
Joel
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200:
Invalid JSON
Posted by Hendrik Jan van Meerveld <ha...@gmail.com>.
Thanx again.
It's good to know that the problem is all ready on the radar.
Kind regards,
Hendrik Jan
On 17 April 2011 19:33, Jan Lehnardt <ja...@apache.org> wrote:
> Hi Jan,
>
> see https://issues.apache.org/jira/browse/COUCHDB-1059 :)
>
> Cheers
> Jan
> --
>
> On 17 Apr 2011, at 18:32, Hendrik Jan van Meerveld wrote:
>
> > Hello Jan,
> >
> > I've tried your changes (by replacing jquery.couch.js with your version)
> but
> > it seems not to be working.
> > The problem seems to be somewhere inside jquery.couch.
> >
> > My understanding of jquery(.couch) is not enough to find and fix the bug.
> > Therefore I hope I can help by giving a description of the problem, so
> > somebody else can fix it.
> >
> > I Hope this helps to create an even better couchdb.
> > Description of the problem:
> >
> > *The dataType property in the ajaxOptions argument is not being used in
> the
> > http request:*
> > My application has a function like this:
> >
> > function showList() {
> > $db.list("main/listbones","bone_objects",null,{
> > *dataType: "html"*,
> > success: function(data){
> > $("#bottenlijst tbody").empty();
> > $("#bottenlijst tbody").append(data);
> > $("#bottenlijst tbody tr").click(loadDoc);
> > },
> > error: function(status, error, reason) {
> > alert(error+" "+status+": "+reason);
> > }
> > });
> > };
> >
> > and the dataType:"html" part is not working (firebug tells request header
> is
> > Accept: application/json, text/javascript, */*)
> >
> > *Hardcoded into jquery.couch.js the dataType property is working:*
> > When I hardcode dataType:"html" into jquery.couch.js like this:
> >
> > list: function(list, view, options, ajaxOptions) {
> > 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,
> > *dataType: 'html'*,
> > data: data,
> > url: this.uri + '_design/' + list[0] +
> > '/_list/' + list[1] + '/' + view +
> encodeOptions(options)
> > },
> > ajaxOptions, 'An error occured accessing the list'
> > );
> > },
> >
> > then the request header (according to firebug) is changed to: Accept:
> > text/html,
> > */*
> >
> > *But even with the correct request header, I get an error:*
> > With the correct header, I still get this error:
> >
> > [object XMLHttpRequest] 200: Invalid JSON: <tr id="row_bot_ulna">
> > <td>bot_ulna</td>
> > <td>arm</td>
> > <td>1</td>
> > </tr>
> >
> > I could not pinpoint which process is generating this error message, but
> I
> > think that it is some function
> > inside jquery.couch.js.
> >
> > *Directly using $.ajax (instead of $.couch.list), my function is working
> as
> > expected.*
> > If I use the $.ajax function directly to retrieve the list, like this:
> >
> > function showList() {
> > $.ajax({
> > type: "GET",
> > *dataType: "html"*,
> > url: mainpath + '/_list/listbones/bone_objects',
> > success: function(data){
> > $("#bottenlijst tbody").empty();
> > $("#bottenlijst tbody").append(data);
> > $("#bottenlijst tbody tr").click(loadDoc);
> > },
> > error: function(status, error, reason) {
> > alert(error+" "+status+": "+reason);
> > }
> > });
> > };
> >
> > then it works as expected without an error message.
> >
> >
> > Kind regards,
> > Hendrik Jan
> >
> >
> >
> >
> >
> > On 17 April 2011 09:45, Hendrik Jan van Meerveld <ha...@gmail.com>
> wrote:
> >
> >> Wow, that was fast!
> >> Thank you for the help, Jan.
> >>
> >> Kind regards,
> >> Hendrik Jan
> >>
> >> On 16 April 2011 22:40, Jan Lehnardt <ja...@apache.org> wrote:
> >>
> >>> 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 <ja...@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
> >>>>>
> >>>>>
> >>>
> >>>
> >>
>
>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON
Posted by Jan Lehnardt <ja...@apache.org>.
Hi Jan,
see https://issues.apache.org/jira/browse/COUCHDB-1059 :)
Cheers
Jan
--
On 17 Apr 2011, at 18:32, Hendrik Jan van Meerveld wrote:
> Hello Jan,
>
> I've tried your changes (by replacing jquery.couch.js with your version) but
> it seems not to be working.
> The problem seems to be somewhere inside jquery.couch.
>
> My understanding of jquery(.couch) is not enough to find and fix the bug.
> Therefore I hope I can help by giving a description of the problem, so
> somebody else can fix it.
>
> I Hope this helps to create an even better couchdb.
> Description of the problem:
>
> *The dataType property in the ajaxOptions argument is not being used in the
> http request:*
> My application has a function like this:
>
> function showList() {
> $db.list("main/listbones","bone_objects",null,{
> *dataType: "html"*,
> success: function(data){
> $("#bottenlijst tbody").empty();
> $("#bottenlijst tbody").append(data);
> $("#bottenlijst tbody tr").click(loadDoc);
> },
> error: function(status, error, reason) {
> alert(error+" "+status+": "+reason);
> }
> });
> };
>
> and the dataType:"html" part is not working (firebug tells request header is
> Accept: application/json, text/javascript, */*)
>
> *Hardcoded into jquery.couch.js the dataType property is working:*
> When I hardcode dataType:"html" into jquery.couch.js like this:
>
> list: function(list, view, options, ajaxOptions) {
> 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,
> *dataType: 'html'*,
> data: data,
> url: this.uri + '_design/' + list[0] +
> '/_list/' + list[1] + '/' + view + encodeOptions(options)
> },
> ajaxOptions, 'An error occured accessing the list'
> );
> },
>
> then the request header (according to firebug) is changed to: Accept:
> text/html,
> */*
>
> *But even with the correct request header, I get an error:*
> With the correct header, I still get this error:
>
> [object XMLHttpRequest] 200: Invalid JSON: <tr id="row_bot_ulna">
> <td>bot_ulna</td>
> <td>arm</td>
> <td>1</td>
> </tr>
>
> I could not pinpoint which process is generating this error message, but I
> think that it is some function
> inside jquery.couch.js.
>
> *Directly using $.ajax (instead of $.couch.list), my function is working as
> expected.*
> If I use the $.ajax function directly to retrieve the list, like this:
>
> function showList() {
> $.ajax({
> type: "GET",
> *dataType: "html"*,
> url: mainpath + '/_list/listbones/bone_objects',
> success: function(data){
> $("#bottenlijst tbody").empty();
> $("#bottenlijst tbody").append(data);
> $("#bottenlijst tbody tr").click(loadDoc);
> },
> error: function(status, error, reason) {
> alert(error+" "+status+": "+reason);
> }
> });
> };
>
> then it works as expected without an error message.
>
>
> Kind regards,
> Hendrik Jan
>
>
>
>
>
> On 17 April 2011 09:45, Hendrik Jan van Meerveld <ha...@gmail.com> wrote:
>
>> Wow, that was fast!
>> Thank you for the help, Jan.
>>
>> Kind regards,
>> Hendrik Jan
>>
>> On 16 April 2011 22:40, Jan Lehnardt <ja...@apache.org> wrote:
>>
>>> 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 <ja...@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
>>>>>
>>>>>
>>>
>>>
>>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200:
Invalid JSON
Posted by Hendrik Jan van Meerveld <ha...@gmail.com>.
Hello Jan,
I've tried your changes (by replacing jquery.couch.js with your version) but
it seems not to be working.
The problem seems to be somewhere inside jquery.couch.
My understanding of jquery(.couch) is not enough to find and fix the bug.
Therefore I hope I can help by giving a description of the problem, so
somebody else can fix it.
I Hope this helps to create an even better couchdb.
Description of the problem:
*The dataType property in the ajaxOptions argument is not being used in the
http request:*
My application has a function like this:
function showList() {
$db.list("main/listbones","bone_objects",null,{
*dataType: "html"*,
success: function(data){
$("#bottenlijst tbody").empty();
$("#bottenlijst tbody").append(data);
$("#bottenlijst tbody tr").click(loadDoc);
},
error: function(status, error, reason) {
alert(error+" "+status+": "+reason);
}
});
};
and the dataType:"html" part is not working (firebug tells request header is
Accept: application/json, text/javascript, */*)
*Hardcoded into jquery.couch.js the dataType property is working:*
When I hardcode dataType:"html" into jquery.couch.js like this:
list: function(list, view, options, ajaxOptions) {
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,
*dataType: 'html'*,
data: data,
url: this.uri + '_design/' + list[0] +
'/_list/' + list[1] + '/' + view + encodeOptions(options)
},
ajaxOptions, 'An error occured accessing the list'
);
},
then the request header (according to firebug) is changed to: Accept:
text/html,
*/*
*But even with the correct request header, I get an error:*
With the correct header, I still get this error:
[object XMLHttpRequest] 200: Invalid JSON: <tr id="row_bot_ulna">
<td>bot_ulna</td>
<td>arm</td>
<td>1</td>
</tr>
I could not pinpoint which process is generating this error message, but I
think that it is some function
inside jquery.couch.js.
*Directly using $.ajax (instead of $.couch.list), my function is working as
expected.*
If I use the $.ajax function directly to retrieve the list, like this:
function showList() {
$.ajax({
type: "GET",
*dataType: "html"*,
url: mainpath + '/_list/listbones/bone_objects',
success: function(data){
$("#bottenlijst tbody").empty();
$("#bottenlijst tbody").append(data);
$("#bottenlijst tbody tr").click(loadDoc);
},
error: function(status, error, reason) {
alert(error+" "+status+": "+reason);
}
});
};
then it works as expected without an error message.
Kind regards,
Hendrik Jan
On 17 April 2011 09:45, Hendrik Jan van Meerveld <ha...@gmail.com> wrote:
> Wow, that was fast!
> Thank you for the help, Jan.
>
> Kind regards,
> Hendrik Jan
>
> On 16 April 2011 22:40, Jan Lehnardt <ja...@apache.org> wrote:
>
>> 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 <ja...@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
>> >>
>> >>
>>
>>
>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200:
Invalid JSON
Posted by Hendrik Jan van Meerveld <ha...@gmail.com>.
Wow, that was fast!
Thank you for the help, Jan.
Kind regards,
Hendrik Jan
On 16 April 2011 22:40, Jan Lehnardt <ja...@apache.org> wrote:
> 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 <ja...@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
> >>
> >>
>
>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON
Posted by Jan Lehnardt <ja...@apache.org>.
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 <ja...@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
>>
>>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200:
Invalid JSON
Posted by Hendrik Jan van Meerveld <ha...@gmail.com>.
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 <ja...@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
>
>
Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON
Posted by Jan Lehnardt <ja...@apache.org>.
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