Unwanted characters using jquery + php

0

I'm having a little problem, when I use the jquery append to display elements returned from a php query.

Note: this is not the full append, it's a bit long and I've just put the part I need you to see.

$("#topics").append('<div class="topic_sumario">'+dados.sumario+'</div>')

The summary is a field in my table of topics that is added and edited with a textarea using tinymce, the problem is that when the append displayed the summary it is appearing all the html tags coming from tinymce, example:

It's like you're not recognizing tags and displaying everything as a string

I want you to recognize all the formatting that tinymce does, such as bold, italic, or the embed of a video etc ... but the way that being is not going to work

    
asked by anonymous 05.12.2017 / 23:50

1 answer

1

Use this native PHP function: html_entity_decode ()

Ex:

<?php
    echo html_entity_decode('&#60;p&#62;teste de &#60;strong&#62;tags&#60;/strong&#62;&#60;/p&#62;');

    // Saída: teste de tags

I recommend that you read the documentation of the function, as there are other extremely important parameters to be passed, since they define the charset of the conversion and how the quotes and apostrophes will be treated.     

07.12.2017 / 00:55