EventSource object used to receive server - sent event notifications - HTML

Q.  Which object is used to receive the server - sent event notifications?
- Published on 28 Aug 15

a. source.onmessage
b. getElementById
c. EventSource
d. echo

ANSWER: EventSource


  • Nirja Shah   -Posted on 06 Nov 15
    EventSource object
    - This object is used to receive server-sent event notifications:

    - Example
    var source = new EventSource("first_page.php");
    source.onmessage = function(event)

    - The above example creates a new EventSource object, and specifies the URL of the page by sending the updates (in this example "first_page.php")

    - The onmessage event occurs each time an update is received,

    - Put the received data into the element with id="result" when an onmessage event occurs.

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)