[英]Laravel: Retrieving a String with tags from a Tables shows HTML Entities on the tags instead
This is in Laravel and its js这是在 Laravel 及其 js
I am trying to retrieve data from the column "message_template" (data type: text).我正在尝试从“message_template”列(数据类型:文本)中检索数据。
in my code, I am using the DataTable plugin for js.在我的代码中,我使用 js 的 DataTable 插件。 "row" retrieves the data from "#main-message-list" “row”从“#main-message-list”中检索数据
let data = $('#main-message-list').DataTable().row( $(this).parents('tr') ).data();
$('#message_template').val(data.message_template);
The issue with the code above is the HTML Entities in the tags are shown instead:上面代码的问题是标签中的 HTML 实体改为显示:
This should be shown normally as <AGE> Years Old
.这通常应显示为<AGE> Years Old
。
What can I add in my DataTable code to fix this Entities issue?我可以在我的 DataTable 代码中添加什么来解决这个实体问题?
Update: Made my code example a bit more clearer.更新:使我的代码示例更加清晰。
You can Use strip_tags
function.您可以使用strip_tags
function。
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
// 允许<p> and <a>
echo strip_tags($text, '<p><a>');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.