JavaScript 'Listening' for Server Events

Discussion in 'JavaScript' started by radicaldr, Mar 8, 2007.

  1. #1
    Is it possible to have a JavaScript event triggered based on a server event?

    for example, let's say I'm trying to create a chat application -
    would the client-side have to constantly send a request to check for new messages, or would the server be able to send an instruction saying that a new message has arrived?
     
    radicaldr, Mar 8, 2007 IP
  2. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #2
    It is not possible for the server to contact the client without a request from the client. Yes, you will have to constantly query the server to know about any server event. You can use Ajax for this purpose so that the user will no know about the querying.
     
    Aragorn, Mar 8, 2007 IP