Hello! How to display the updated information without any handlers, that is, as soon as something has changed in the mysql database so that the page displays the changed data
.....

request.open("GET"url,true); .. request.onreadystatechange = function () { if(request.readyState != 4)return; if(request.status = 200) { document.GetElementByID("somediv").innerHtml = request.responseText; } } 

This code works, but shows updated data only after a reboot, probably because there is no handler.

    2 answers 2

    1. if (request.status = = 200) // missed =
    2. This function must be performed all the time, not once.
    3. If you want an immediate response to changes - look in the direction of webSocket (but I think this is still superfluous)
    • 1 well, I changed = to == the same 2 but how to perform all the time? there are no clicks buttons; you just need to change a new value in the next message when changing some cells in the database . orik80
    • one

    So make a request regularly on a timer.

    • Will it not load the page? - orik80
    • I mean the extra load on the server - orik80
    • Naturally will. Want to do no-load actions? It’s like pushing up and not getting tired) I don’t think that you have a 5 gig base there so that the load can be felt strongly. The main thing is not once a second, but 10 at least (and this is often the case). - Sh4dow
    • Right. How do I get the data? the load should not be too large, only the loading interval is reasonable. - Oleg Arkhipov
    • This is not suitable because the data should be shown immediately after the change, for example, as in a chat or postal service. let's say the user has messages saved in the database now 10 messages and after 5 seconds 11 and as soon as the number has changed, you need to display them or for example in the chat someone wrote to the user and the changed content should immediately appear - orik80