I'm recieving a string (it may be either plain text or HTML text) from server, and I need to insert it into a div after that.
I can use $div.text(textFromServer) if I know that textFromServer is plain text.
If I know that textFromServer is html I can do something like $(textFromServer).appendTo($div).
The problem is that I don't know for sure whether textFromServer is plain or HTML.
So here's the question: is there a elegant and simple solution for my problem? Or do I have to analyse textFromServer?
Simply use html():
$div.html(textFromServer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With