Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 94732 invoked from network); 17 Apr 2011 18:32:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Apr 2011 18:32:03 -0000 Received: (qmail 38350 invoked by uid 500); 17 Apr 2011 18:32:01 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 38316 invoked by uid 500); 17 Apr 2011 18:32:01 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 38308 invoked by uid 99); 17 Apr 2011 18:32:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 18:32:01 +0000 X-ASF-Spam-Status: No, hits=2.1 required=5.0 tests=FREEMAIL_FROM,HK_RANDOM_ENVFROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of haaiee@gmail.com designates 209.85.216.173 as permitted sender) Received: from [209.85.216.173] (HELO mail-qy0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 18:31:52 +0000 Received: by qyk36 with SMTP id 36so907906qyk.11 for ; Sun, 17 Apr 2011 11:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=TKK6A8MKsEhuHD7ptk1H/tLT2prN6U7jJvkI2H79XQ0=; b=ZeMltEUxN5lGWG/0oeQpgR14EXHgi7KhZWz4JYRDPZat18iMi9yAOehzsNMSS/vl54 bXHlU8+j9EqrYpwZUuVZMJWx55CD7JRTgixmFSlD+zjQLvRHIU+JP/POV86uIMpsKefz XpYR1f/DugdauRILFn4iI2kQ3pcHYF1KwpDtI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=ojSYOafuJdhePlmi0iuSU1EWxDyFr0r2SJ3TF0hnhdAUSXNZcNn0AiWMbOwzLNaTpz TxdBFxtc81upMuN5wTn+ge3unkNyjSTu6KLb2a0aG1zU5QxXbi2qI5U953RWWpZoLA/b zzrmi+cu8aI1Zv4y6VyYnZOZqiuGTKoAucyZ4= Received: by 10.229.63.143 with SMTP id b15mr2925460qci.136.1303065091113; Sun, 17 Apr 2011 11:31:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.181.206 with HTTP; Sun, 17 Apr 2011 11:31:11 -0700 (PDT) In-Reply-To: <65326A35-EE4F-4978-8256-91123491B7D3@apache.org> References: <7F79CD98-57ED-4C60-A7CF-5EEFDAF47739@apache.org> <48D12968-59D2-4805-AA97-75244ECE5A73@apache.org> <65326A35-EE4F-4978-8256-91123491B7D3@apache.org> From: Hendrik Jan van Meerveld Date: Sun, 17 Apr 2011 20:31:11 +0200 Message-ID: Subject: Re: $.couch.db(dbname).list("dbname/listname","viewname") --> 200: Invalid JSON To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016e64f45e8e001bc04a1217b72 X-Virus-Checked: Checked by ClamAV on apache.org --0016e64f45e8e001bc04a1217b72 Content-Type: text/plain; charset=ISO-8859-1 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 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: > > bot_ulna > > arm > > 1 > > > > > > 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 > wrote: > > > >> Wow, that was fast! > >> Thank you for the help, Jan. > >> > >> Kind regards, > >> Hendrik Jan > >> > >> On 16 April 2011 22:40, Jan Lehnardt 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 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: