Answer the question
In order to leave comments, you need to log in
How to send a message to yourself on Socket.io?
Hello, I'm still learning how to use Socket.io and now I'm trying to make
registration form validation. The bottom line is, if a person entered a username that is
already in the database, then an error message is displayed to him.
But it turns out that the error message is displayed to everyone who is on the
registration page. Q: Does Socket.io have a method to send data to itself?
PS: Is it better to use Ajax for my task?
It’s just that I haven’t worked with Ajax yet, but Socket.io is quite satisfactory for me so far.
Answer the question
In order to leave comments, you need to log in
Found the answer. It turns out it's easy. Just io.emit()
write insteadsocket.emit()
But it turns out that the error message is displayed to everyone who is on the
registration page.
It's just that I haven't worked with Ajax yet, but Socket.io suits me quite well so far.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question