How to stop an html TEXTAREA from decoding html entities

后端 未结 6 1218
眼角桃花
眼角桃花 2021-01-01 12:46

I have a strange problem:

In the database, I have a literal ampersand lt semicolon:

<div  

whenever its printed into a html

6条回答
  •  一整个雨季
    2021-01-01 12:56

    You can serve your DB-content from a separate page and then place it in the textarea using a Javascript (jQuery) Ajax-call:

    request = $.ajax
    ({  
        type: "GET",
        url: "url-with-the-troubled-content.php",           
        success: function(data)
        {
            document.getElementById('id-of-text-area').value = data;    
        }
    }); 
    

    Explained at

    http://www.endtask.net/how-to-prevent-a-textarea-element-from-decoding-html-entities/

提交回复
热议问题