添加标签html< a>基于数据的Ajax源数据 [英] Add tag html <a> on datatable Ajax sourced data

查看:190
本文介绍了添加标签html< a>基于数据的Ajax源数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 < td>< a href = review / data.html?id =<?php echo $ _POST ['id']?>>动作< / a>< / td> 

但是我不能使用添加标签HTML中的Ajax源数据

  $(document).ready(function(){
$('#example')。DataTable({
ajax:
data:du_id},
{data:site_id},
data :status},
{data:submission_end_time},
{data:region},
{data:'< a href = '+id+'>< / a>'}
]
});
});


解决方案

有几种方法可以做到这一点,是通过使用 defaultContent ,或者您可以使用 render ,这给了我更多的灵活性。我认为:

 < code $ {data:submission_end_time},
{data:region},
{
'render':function(data,type,full, meta){
return'< a href ='+ data +'>< / a>';
}
}


I use add tag link in basic sourced data which it work.

<td><a href="review/data.html?id=<?php echo $_POST['id'] ?>">Action</a></td>

But i not work to Ajax sourced data in add tag html

 $(document).ready(function() {
    $('#example').DataTable( {
        "ajax": "api/all",
        "columns": [
            { "data": "du_id" },
            { "data": "site_id" },
            { "data": "status" },
            { "data": "submission_end_time" },
            { "data": "region" },
            { "data": '<a href="'+"id"+'"></a>' }
        ]
    } );
} );

解决方案

There are a few ways you can do this, one is by using defaultContent, or you can use render which gives more flexibility I think:

{ "data": "submission_end_time" },
{ "data": "region" },
{
    'render': function (data, type, full, meta) {
        return '<a href="'+ data +'"></a>';
        }
}

这篇关于添加标签html&lt; a&gt;基于数据的Ajax源数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆