What Paulo is saying is right. While your approach will result in a working application, I strongly discourage using long polling (whenever it can be avoided) especially on the client side. It will put a lot of unnecessary load on your server and will prevent it from scaling well. There is a reason why websockets are pretty much a best practice for chat application :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What Paulo is saying is right. While your approach will result in a working application, I strongly discourage using long polling (whenever it can be avoided) especially on the client side. It will put a lot of unnecessary load on your server and will prevent it from scaling well. There is a reason why websockets are pretty much a best practice for chat application :)