jquery-longpoll-client
Version:
Simple client-side longpoll implementation
45 lines (33 loc) • 657 B
Markdown
Simple client-side longpoll implementation.
```javascript
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:
```json
{
"params": {"t": 1485714250},
"data": "any kind of data will be passed to callback function"
}
```
```javascript
jQuery.longpoll.get('myId').stop();
```
```javascript
jQuery.longpoll.destroy('myId');
```
License
-------
BSD-3-Clause