Skip to content

Izumi-kun/jquery-longpoll-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery LongPoll client script

Simple client-side longpoll implementation.

Usage

Create

var config = {
  url: '/url/to/polling',
  params: {t: 1485714246},
  callback: function (data) {
    // your callback function
    console.log(data);
  }
};
jQuery.longpoll.register('myId', config).start();

The server should return JSON data in follow structure:

{
  "params": {"t": 1485714250}, 
  "data": "any kind of data will be passed to callback function"
}

Stop

jQuery.longpoll.get('myId').stop();

Destroy

jQuery.longpoll.destroy('myId');

License

BSD-3-Clause