Hi All,

I’m having an issue with monitoring the changes feed of a database on Couchdb 
1.6. I’m using jQuery to monitor the changes feed of a database. I’ve set it to 
feed type to longpoll and I’ve set a hearbeat of 3 seconds. I want the request 
to return after 3 seconds if no changes happened on the document. This works 
perfectly via curl using this:

curl 
'http://127.0.0.1:5984/MY_DB/_changes?feed=longpoll&since=now&heartbeat=3000&include_docs=true'
 
<http://127.0.0.1:5984/MY_DB/_changes?feed=longpoll&since=now&heartbeat=3000&include_docs=true'>

But if I try and do the exact same via jQuery it never returns. Any ideas on 
why it doesn’t and what I’m doing wrong? Here are steps to reproduce with 
jQuery:

Ppen fauxton in browser: http://localhost:5984/_utils/fauxton/ 
<http://localhost:5984/_utils/fauxton/>
Open the dev console.
Run this code snippet:

function longpoll(last_seq) { 
 var query = $.param({
       since: last_seq || "now",
       include_docs: true,
       feed: 'longpoll',
       heartbeat: 3000
     });
 
  console.log('query ' + query);
     var promise = $.get('/qa_multi_1/_changes?' + query);
     promise.then(function (resp) {
        var parsedResp = JSON.parse(resp),
            results = parsedResp.results,
            last_seq = parsedResp.last_seq;
 
        console.log('changes', resp, parsedResp);
        
        longpoll(last_seq);
      });
}
longpoll("now");


Any help greatly appreciated
Garren

Reply via email to