couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Rhoads <bdr...@gmail.com>
Subject Re: CouchDB: JSON Callback
Date Tue, 30 Jul 2013 18:24:01 GMT
JQuery makes this easy.

There's an about page in our chouchapp with  button to check for an app
update in iriscouch. I store the revision number in a appinfo.json
document.

I had to issue the check unconditionally at the top of the page. So all the
button actually does is check the value of a global flag.

    //JSONP can't be done synchronous so we have to test for software
updates on every load of this page.

    var updateAvailable = false;

    var remoteVersion = 0;

$.ajax({

    url: templateDB +'/appinfo',

 *   contentType: "application/json",*

*     dataType:"jsonp",*

    success: function (remoteAppInfo) {

    remoteVersion = remoteAppInfo[env]["version"];

    updateAvailable = (parseFloat(version) < parseFloat(remoteVersion));

    }

  });

---------------------------
www.maf.org/rhoads
www.ontherhoads.org


On Tue, Jul 30, 2013 at 3:19 AM, Robert Newson <rnewson@apache.org> wrote:

> Enable JSONP (
> http://docs.couchdb.org/en/latest/config_reference.html#httpd-configuration-options
> )
> and then add ?callback=foo. couchdb will then return foo({"rows"... );
>
> I failed to find a write-up of JSONP in our manual or even a mention
> on the wiki, sorry about that.
>
> B.
>
>
> On 30 July 2013 01:06, Hank Knight <hknight555@gmail.com> wrote:
> > Results are returned in JSON format:
> >
> https://zurv3aqzm.iriscouch.com/fruit/_design/zzz6/_view/zzz6?limit=101&group=true
> >
> > Is there a way to wrap the JSON in a way that could be used for a
> callback?
> >
> > Like this:
> >
> > xyz({"rows":[
> > {"key":"blueberry","value":1},
> > {"key":"cranberry","value":1},
> > {"key":"gooseberry","value":3},
> > {"key":"grapefruit","value":2},
> > {"key":"lemon","value":1},
> > {"key":"lime","value":1},
> > {"key":"orange","value":1},
> > {"key":"peach","value":2},
> > {"key":"plumb","value":1},
> > {"key":"strawberry","value":4},
> > {"key":"watermelon","value":2}
> > ]})
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message