繁体   English   中英

为什么我使用tinymce textarea作为输入在php中看到html标签?

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

我在TinyMCE上遇到问题。 当我将TinyMCE textarea内容(使用jQuery)加载到数据库中,然后在php页面上看到结果时,我看到了html标签...在图片中您可以找到一个示例。

在此输入图像描述

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();
            }
        });
  });
});

输出查询

$(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>");
                });

        }
    );
});

所有编辑器WYSWYG都将内容转换为html实体。 您应该使用此库作为示例:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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