我在我的项目中使用了datatble,除了一个问题之外,一切都运行得很好。
当我的数据之一为<script> alert('hello world')</script>时,将显示警报,而不是在我的表中写入"<script> alert('hello world')</script>",我如何防止这种情况发生?我的代码看起来像这样:
$('.datatable_selector').DataTable({
"serverSide": true,
"processing": true,
"ajax" : {
"url" : "http://myurl.com"
},
"columns" : [
{"data" : "data1"},
{"data" : "problemData"}
]
})发布于 2019-10-11 16:15:23
根据DataTables documentation,您应该使用呈现函数:
{
data: 'product',
render: $.fn.dataTable.render.text()
}https://stackoverflow.com/questions/58336913
复制相似问题