Question

I want to know what is exactly AJAX heartbeat pattern and what is the difference between it and jquery setInterval

Because im making an AJAX chat and I don't want to pull the data every 15 seconds I want to make a connection to the server to avoid delay is that what called heartbeat ? Also I want a good tutorial to make this or any suggestion from you

Note: I have completed the implementation with setInterval but I saw that heartbeat is better way to avoid delay

Was it helpful?

Solution

Heartbeat is a design pattern, this means it's a way of coding solutions.

Here a technique is meant, where you keep sending requests to the server, so the server knows the user/browser is still present. There are several use-cases for this pattern, for example to prevent timeouts of sessions etc.

You cannot really compare a design pattern to a function, because setInterval could be used to implement this pattern. You would keep sending request in a specified interval.

I don't have a tutorial at hand, but the first hits on google already contain some examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top