When I send signals back to the client from an Ajax request, I use this form:
<!--a_b-->
so if some how I don’t parse it, and it ends up in the html it won’t break anything because it is a comment.
a and b denote values to convey information while _ is a separator.
I can’t but help wonder how others send “control” signals back from an ajax request.
What is the best way to send control signals from the server to the client using ajax?
I would just use JSON. Your client has to know how to interpret the response anyway, so encoding it in a html comment isn’t really useful. It just means you need extra work to parse later. The
if some how I don't parse itjust means you have a bug you should fix.