I'm implementing a very basic long-polling scenario in my web-app to get server notifications. That's my client-side code
(function poll()
{
$.ajax({ url: "server.php", success: function( data )
{
// data management
}, dataType: "json", complete: poll, timeout: 15000 });
})();
On the server side there is a simple while(true) loop that waits for a new message and then prints out the result. It works; it's, however, not working as it should: the message sent from the server is received by the client whenever the timeout expires and the function poll is called again and not whenever the server fires up the notification (as it is supposed to be).
Any ideas why it's working as a "setInterval" and not as it should? Thanks