incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Gable <zi...@ignition-project.com>
Subject Re: How To Retrieve JUST The Latest Rev Of A (Design) Doc - Check For CouchApp Update
Date Sun, 07 Apr 2013 20:31:33 GMT
JSONP cannot return headers or errors in most cases. This is because JSONP
is loaded as a <script /> tag, and so either the code executes or it
doesn't. Also, you may only GET with JSONP. jQuery is likely logging an
error to this effect.

If you are using PhoneGap, you can allow cross-site scripting using their
whitelist. Otherwise, you can try to set up CORS. Then, use a normal Ajax
request.

There are also a few libraries which do browser-specific things to make
JSONP less crappy, but I don't think they'll work for you.

---
Keith Gable
A+, Network+, and Storage+ Certified Professional
Apple Certified Technical Coordinator
Mobile Application Developer / Web Developer


On Sat, Apr 6, 2013 at 11:11 PM, Brad Rhoads <bdrhoa@gmail.com> wrote:

> It looks like that a HEAD request should work. But in my code below, it
> doesn't appear that either the error function or the success function get
> called. Note that async:true doesn't make any difference.
>
>
>     // Check for application updates
>
>     $('input.updatecheck').live('click', function (event) {
>
>
>
>      var geturl;
>
>       geturl = $.ajax({
>
>         type: "HEAD",
>
>         dataType:"jsonp", //need to use JSONP to get to isriscouch
>
>         async: false,
>
>         url: '
> http://user:password@ourdomain.iriscouch.com/ourdb/_design/library',
>
>         error:function (){alert("fail!");},
>
>         success: function () {
>
>           alert("done!"+ geturl.getAllResponseHeaders());
>
>         }
>
>       });
>
>       . . .
>
>  });
>
>
>
> ---------------------------
> www.maf.org/rhoads
> www.ontherhoads.org
>
>
> On Sat, Apr 6, 2013 at 11:37 AM, Marty Schoch <marty.schoch@gmail.com
> >wrote:
>
> > A HEAD request for the document should return the revision (I think it
> may
> > be in the Etag header)
> >
> > Marty
> > On Apr 6, 2013 12:58 PM, "Brad Rhoads" <bdrhoa@gmail.com> wrote:
> >
> > > We're running a couchapp on TouchDB Android. The app has a "check for
> > > update" option that of course, just starts a replication against the
> the
> > > version running online. But I'd like to tell the user either "update in
> > > progress" or "no update available."
> > >
> > > It seems that I should just need to compare the rev of the local
> _design
> > > doc against the remote _design doc. Is there a way to request just the
> > _rev
> > > of the remote doc? So far I've only been able to retrieve the entire
> > > document, which in the case of a couchapp is pretty big.
> > >
> > > As I was just writing that, it came to mind that I might just be better
> > off
> > > creating a separate document that has a last update/version number in
> it.
> > >
> > > Any other approaches to this problem?
> > >
> > > Thanks for the help!
> > > ---------------------------
> > > www.maf.org/rhoads
> > > www.ontherhoads.org
> > >
> >
>

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