1

Specifically <br>. I have this data stored in my database Category#1<br>Category#2<br>Category#3

When I display them after a successful ajax request, I get exactly what was stored in the database. When I try to edit via console, it then will recognize the <br>.

How I got the data:

var category = response.items[index].category;

How I display it:

var cat = $('<td />', { text: category }).appendTo(tr);

2 Answers 2

2

Use html instead of text

ar cat = $('<td />', { html: category }).appendTo(tr);

Because, if you use text it will treat the string as text, which causes the problem.

If you use html, it will treat the string as html

Sign up to request clarification or add additional context in comments.

Comments

2

change this in your code:

html: category

.text() processes the html string as a text so it does not parse it as html if you have html tags in it. .html() method which parses the html string as a html.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.