You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Tom Bichay <bi...@gmx.net> on 2010/09/22 15:10:10 UTC
Continuous Feed usage with CouchDB
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 is wrong with my code?
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
--
BICHAY IT [bi:shay]
IT | Consulting | Development
Tom Bichay
Freelancer
Kammachergasse 2
89073 Ulm
0151 - 20669066
tom@bichay.de | bichay@gmx.net
www.bichay.de
Re: Continuous Feed usage with CouchDB
Posted by Anton Podviaznikov <po...@gmail.com>.
Hello,
I don't understand what you mean under
> > try using feed=longpoll, and having your callback function open the
connection again.
let's say I has code
var connection=$.ajax({
url: "my_url",
dataType: "jsonp",
jsonp: "my_callback",
feed:"longpoll"
});
connection.onreadystatechange = my_callback;
How can I modify the code to open connection in the callback function?
Thanks a lot
Tom Bichay <bi...@...> writes:
>
> Hi Chris,
>
> thanks for the reply again.
>
> Yes! You replied already. I wrote this message in the mailing list before I
wrote you directly. But thanks again.
>
> I managed it now with longpoll and I just invoke another call to the view with
it. Now it seems to work quite
> good.
> As you told me.
>
> Thanks again.
>
> Cheers,
> Tom
>
> Am 26.09.2010 um 01:17 schrieb Chris Anderson:
>
> > On Wed, Sep 22, 2010 at 6:10 AM, Tom Bichay <bi...@...> wrote:
> >> Hi,
> >>
> >> I just need a way to invoke a function for each new arriving json.
> >
> > I thought I replied once before, but just in case:
> >
> > try using feed=longpoll, and having your callback function open the
> > connection again.
> >
> > this is much more reliable. also, I can't see how continuous could
> > work with JSONP, even in theory.
> >
> >>
> >> Thanks
> >> Tom
> >> --
> >> BICHAY IT [bi:shay]
> >> IT | Consulting | Development
> >> Tom Bichay
> >> Freelancer
> >>
> >> Kammachergasse 2
> >> 89073 Ulm
> >> 0151 - 20669066
> >> tom@... | bichay@...
> >> www.bichay.de
> >>
> >>
> >
> >
> >
> > --
> > Chris Anderson
> > http://jchrisa.net
> > http://couch.io
>
Re: Continuous Feed usage with CouchDB
Posted by Tom Bichay <bi...@gmx.net>.
Hi Chris,
thanks for the reply again.
Yes! You replied already. I wrote this message in the mailing list before I wrote you directly. But thanks again.
I managed it now with longpoll and I just invoke another call to the view with it. Now it seems to work quite good. :-)
As you told me.
Thanks again.
Cheers,
Tom
Am 26.09.2010 um 01:17 schrieb Chris Anderson:
> On Wed, Sep 22, 2010 at 6:10 AM, Tom Bichay <bi...@gmx.net> wrote:
>> Hi,
>>
>> I just need a way to invoke a function for each new arriving json.
>
> I thought I replied once before, but just in case:
>
> try using feed=longpoll, and having your callback function open the
> connection again.
>
> this is much more reliable. also, I can't see how continuous could
> work with JSONP, even in theory.
>
>>
>> Thanks
>> Tom
>> --
>> BICHAY IT [bi:shay]
>> IT | Consulting | Development
>> Tom Bichay
>> Freelancer
>>
>> Kammachergasse 2
>> 89073 Ulm
>> 0151 - 20669066
>> tom@bichay.de | bichay@gmx.net
>> www.bichay.de
>>
>>
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
--
BICHAY IT [bi:shay]
IT | Consulting | Development
Tom Bichay
Freelancer
Kammachergasse 2
89073 Ulm
0151 - 20669066
tom@bichay.de | bichay@gmx.net
www.bichay.de
Re: Continuous Feed usage with CouchDB
Posted by Chris Anderson <jc...@apache.org>.
On Wed, Sep 22, 2010 at 6:10 AM, Tom Bichay <bi...@gmx.net> wrote:
> Hi,
>
> I just need a way to invoke a function for each new arriving json.
I thought I replied once before, but just in case:
try using feed=longpoll, and having your callback function open the
connection again.
this is much more reliable. also, I can't see how continuous could
work with JSONP, even in theory.
>
> Thanks
> Tom
> --
> BICHAY IT [bi:shay]
> IT | Consulting | Development
> Tom Bichay
> Freelancer
>
> Kammachergasse 2
> 89073 Ulm
> 0151 - 20669066
> tom@bichay.de | bichay@gmx.net
> www.bichay.de
>
>
--
Chris Anderson
http://jchrisa.net
http://couch.io