Javascript: listen to server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Macinbomzh
    New Member
    • Nov 2009
    • 11

    Javascript: listen to server

    Is there a way in JavaScript to command the browser to listen to a specific location? i.e. a stream of data
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    could you explain that requirement in more detail please? ... you could always poll ... but it is a bit more advanced in case you want to have a persistent connection due to the stateless character of http connections ...

    kind regards

    Comment

    • Macinbomzh
      New Member
      • Nov 2009
      • 11

      #3
      I am writing a live-chat, clients will send data to server and the server will send the data to all clients currently connected.
      I need the client to listen for that data.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        then the easiest way would be to poll a service with an interval like:

        Code:
        var interval = window.setInterval(function() {
            // service call logic here, could even be a function-cll with the logic
        }, 30000);
        this calls the commented code every 30s ...

        kind regards

        Comment

        Working...