我在我的项目中使用了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"}
]
})
根据DataTables文档,您应该使用render函数:
{
data: 'product',
render: $.fn.dataTable.render.text()
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句