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 <[email protected]> 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 <[email protected]> > wrote: > > > >> Wow, that was fast! > >> Thank you for the help, Jan. > >> > >> Kind regards, > >> Hendrik Jan > >> > >> On 16 April 2011 22:40, Jan Lehnardt <[email protected]> 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 <[email protected]> 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 > >>>>> > >>>>> > >>> > >>> > >> > >
