couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: continuous connection with jquery
Date Fri, 24 Sep 2010 19:57:53 GMT
continuous and jsonp are incompatible. use longpoll

On Tue, Sep 21, 2010 at 10:06 AM, Tom Bichay <bichay@gmx.net> wrote:
>
> Hi,
>
> I am trying to implement a continuous _changes connection to couchdb (cloudant) with
jQuery from a different domain (that's why I am using JSONP).
>
> With:
>
> $.ajax({
>           url: "http://app264565.heroku.cloudant.com/geocha/_changes?filter=channel/messages_for&include_docs=true&feed=continuous&channel="+geocha.channelId,
>           dataType: "jsonp",
>           jsonp: "geocha.chat.stateChanged"
>         });
>
> where "geocha.chat.stateChanged" is my callback function, I would expect to get invoked
each time the continuous connection gets a new object.
>
> But it does not.
>
> It connects correctly to the correct couchdb server and I can inspect the correct returned
json (even when I am saving new documents), but I am not able to invoke any function for changes.
> I tried to append an onreadystatechange event listener:
>
> var connection = $.ajax({
>           url: "http://app264565.heroku.cloudant.com/geocha/_changes?filter=channel/messages_for&include_docs=true&feed=continuous&channel="+geocha.channelId,
>           dataType: "jsonp",
>           jsonp: "geocha.chat.stateChanged"
>         });
>
> connection.onreadystatechange = geocha.chat.stateChanged;
>
> But as a JSONP-Connection is not a real XMLHttpRequest object that is not possible.
>
>
> Does anyone know what I am doing wrong?
>
> I tried heaps of different things ($.get, $.getJSON, $.jsonp plugin). But it is always
the same problem.
>
> I just need a way to invoke a function for each new arriving json.
>
> Thanks
> Tom



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Mime
View raw message