简体   繁体   中英

why I see html tag in php using tinymce textarea for input?

I've a problem with TinyMCE. When I load the TinyMCE textarea content (with jQuery) into my database, and then I see the result on a php page, I see html tag...in the picture you can find an example.

在此输入图像描述

HTML

<div class="container pt">
        <!-- +++++ Posts Lists +++++ -->
        <div class="row mt">
            <div class="col-lg-6 col-lg-offset-3 centered">
                <h3>MY BLOG</h3>
                <hr>
            </div>
        </div>
        <div id="white">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-lg-offset-2" id="menublog">

                    </div>
                </div><!-- /row -->
            </div> <!-- /container -->
        </div><!-- /white -->
    </div>

JQuery

$(document).ready(function() {
  $("#Insert").click(function(){
    event.preventDefault();
    var user = "2", titolo = $('#titolo').val(), articolo = tinyMCE.activeEditor.getContent({format : 'raw'}); 
    var id_immagine = $('#menuimmagini').val();
    alert(id_immagine);
    object = JSON.stringify({r: 'InsertPost', u: user, t: titolo, a: articolo, i:id_immagine});
    $.post("server.php", { js_object: object }, 
        function(msg){
            console.log(msg);
            if(msg)
            {
                alert("Post inserito con successo!");
                location.reload();
            }
        });
  });
});

OUTPUT JQUERY

$(document).ready(function() {
    event.preventDefault();
    object = JSON.stringify({r: 'InitializeBlog'});
    $.post("servo.php", { js_object: object }, 
        function(response)
        {   
            var obj = jQuery.parseJSON(response);

            $.each( obj, function( index ) {
                    $('#menublog').append("<p><img class=\"img-circle\" src=\"assets/img/user.png\" width=\"50px\" height=\"50px\"> <ba>Salvo Bertoncini</ba></p> <p><bd>Posted on "+obj[index].date+"</bd></p> <h4>"+obj[index].title+"</h4> <p><img class=\"img-responsive\" src=\"show.php?id="+obj[index].idimmagine+"\"></p> "+obj[index].articles+" <p><a href=\"article.php?id="+obj[index].id+"\">Continue Reading...</a></p><hr>");
                });

        }
    );
});

All editor WYSWYG convert the content to html entities. you should use this library for example:

http://www.strictly-software.com/htmlencode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM