1
I have an application that reads in ajax a Mysql database, which in it is written a normal content (without escaping) with multiple words between double quotes, single or single quotes.
This content goes to a variable, ex:
conteúdo que está no banco de dados...= Quantos litros d'água está "sujo"
wVar = conteúdo acima
I have to show this by concatenating with another text, like:
alert("texto = "+wVar);
It’s like I’m trying to show off "texto = "+"Quantos litros d'água está "sujo""
Ai gives error, logically because the double quotation marks of the word "dirty" are not escaped.
How can I display these phrases correctly without knowing exactly what content will be loaded from the database in the variable?
Note: In the display the word "dirty" needs to be displayed with double quotes, as it is part of the correct content of the text.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings
– Don't Panic