Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将数据发布到a<;a>;带有jquery的元素_Php_Jquery_Datatables 1.10 - Fatal编程技术网

Php 如何将数据发布到a<;a>;带有jquery的元素

Php 如何将数据发布到a<;a>;带有jquery的元素,php,jquery,datatables-1.10,Php,Jquery,Datatables 1.10,我使用DataTables在我运行的报告网站上格式化我的表。我正在使用初始化向表的第一列添加超链接。有没有办法让它看起来像一个按钮而不是一个超链接 我之所以需要它,是因为我有超链接将整行作为链接的一部分发送(因此通过GET),但由于GET中的字符限制,它失败了。我需要使用POST,以便发送更多的数据 超链接的定义是: data = '<a href="FormToEdit.php?everything=\'' + encodeURIComponent(row) + '\'">' +

我使用DataTables在我运行的报告网站上格式化我的表。我正在使用初始化向表的第一列添加超链接。有没有办法让它看起来像一个按钮而不是一个超链接

我之所以需要它,是因为我有超链接将整行作为链接的一部分发送(因此通过
GET
),但由于
GET
中的字符限制,它失败了。我需要使用
POST
,以便发送更多的数据

超链接的定义是:

data = '<a href="FormToEdit.php?everything=\'' + encodeURIComponent(row) + '\'">' + data + '</a>';
data=”;
下面是在上下文中显示超链接的完整datatables初始化:

$.fn.dataTable.ext.buttons.export =
{
    className: 'buttons-alert',
    "text": "Export All Test",
    action: function (e, dt, node, config)
    {
        alert('Export All Test');
    }
};

$(document).ready(function ()
{
    // Setup - add a text input to each footer cell
    $('#DataTableEdit tfoot th').each(function ()
    {
        var title = $(this).text();
        $(this).html('<input type="text" placeholder="Search ' + title + '" />');
    });

    var table = $('#DataTableEdit').DataTable({
        "lengthMenu": [[25, 50, 75, 100, 150, -1], [25, 50, 75, 100, 150, 'All']],
        "dom": '<"top"Bifpl<"clear">>rt<"bottom"ip<"clear">>',
        "buttons": [{
            extend: 'collection',
            text: 'Selection',
            buttons: ['selectAll', 'selectNone']
        }, {
            extend: 'collection',
            text: 'Export',
            buttons: ['export', 'excel', 'csv', 'pdf', { extend: 'excel',
                text: 'Export Current Page',
                exportOptions: {
                    modifier: {
                        page: 'current'
                    }
                },
                customize: function (xlsx)
                {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];
                    $('row:first c', sheet).attr('s', '7');
                }
            },

            {
                text: 'Export All to Excel',
                action: function (e, dt, button, config)
                {
                    dt.one('preXhr', function (e, s, data)
                    {
                        data.length = -1;
                    }).one('draw', function (e, settings, json, xhr)
                    {
                        var excelButtonConfig = $.fn.DataTable.ext.buttons.excelHtml5;
                        var addOptions = { exportOptions: { 'columns': ':all'} };

                        $.extend(true, excelButtonConfig, addOptions);
                        excelButtonConfig.action(e, dt, button, excelButtonConfig);
                    }).draw();
                }
            }]
        }
        ],
        "fixedHeader": {
            header: true,
            footer: true
        },
        "select": true,
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "./ServerSide.php",
            "type": "POST"
        },
//This is the part that adds the hyperlink
        columnDefs: [
        {
            targets: 0,
            render: function (data, type, row, meta)
            {
                if (type === 'display')
                {
                    data = '<a href="FormToEdit.php?everything=\'' + encodeURIComponent(row) + '\'">' + data + '</a>';
                }
                return data;
            }
        }],
//End of hyperlink creation
        initComplete: function ()
        {
            var api = this.api();

            // Apply the search
            api.columns().every(function ()
            {
                var that = this;

                $('input', this.footer()).on('keyup change', function ()
                {
                    if (that.search() !== this.value)
                    {
                        that
                          .search(this.value)
                          .draw();
                    }
                });
            });
        }
    });
});
$.fn.dataTable.ext.buttons.export=
{
className:“按钮警报”,
“文本”:“导出所有测试”,
动作:函数(e、dt、节点、配置)
{
警报(“导出所有测试”);
}
};
$(文档).ready(函数()
{
//设置-向每个页脚单元格添加文本输入
$('#DataTableEdit tfoot th')。每个(函数()
{
var title=$(this.text();
$(this.html(“”);
});
变量表=$('#DataTableEdit')。DataTable({
“长度菜单”:[[25,50,75,100,150,-1],[25,50,75,100,150,'全部'],
“dom”:“rt”,
“按钮”:[{
扩展:'集合',
文本:“选择”,
按钮:['selectAll','selectNone']
}, {
扩展:'集合',
文本:“导出”,
按钮:[“导出”、“excel”、“csv”、“pdf”、{扩展:“excel”,
文本:“导出当前页面”,
出口选择:{
修饰语:{
页面:“当前”
}
},
自定义:功能(xlsx)
{
var sheet=xlsx.xl.worksheets['sheet1.xml'];
$('row:first c',sheet).attr('s','7');
}
},
{
文本:“全部导出到Excel”,
动作:功能(e、dt、按钮、配置)
{
dt.one('preXhr',函数(e,s,数据)
{
data.length=-1;
}).one('draw',函数(e、设置、json、xhr)
{
var excelButtonConfig=$.fn.DataTable.ext.buttons.excelHtml5;
var addOptions={exportOptions:{'columns':':all'}};
$.extend(true、excelButtonConfig、addOptions);
excelButtonConfig.动作(e、dt、button、excelButtonConfig);
}).draw();
}
}]
}
],
“fixedHeader”:{
标题:对,
页脚:对
},
“选择”:true,
“处理”:对,
“服务器端”:正确,
“ajax”:{
“url”:“../ServerSide.php”,
“类型”:“职位”
},
//这是添加超链接的部分
columnDefs:[
{
目标:0,
呈现:函数(数据、类型、行、元)
{
如果(类型==‘显示’)
{
数据='';
}
返回数据;
}
}],
//超链接创建结束
initComplete:函数()
{
var api=this.api();
//应用搜索
api.columns().every(函数()
{
var=这个;
$('input',this.footer()).on('keyup change',function()
{
if(that.search()!==此.value)
{
那个
.search(此.value)
.draw();
}
});
});
}
});
});

如果我没有足够的信息,请告诉我,我会添加更多信息。

您可以尝试将其封装在
标签内,以便将其作为post提交

if (type == 'display'){

    data = '<form action="FormToEdit.php" method="post"><button type="submit" 
           class="btn-as-link" value = \'' +
           encodeURIComponent(row) + '\'>' + data + '</button></form>' ;  
}

你不能把它放在
里面吗?我想可以,但是我怎么才能把我现在放在
get
中的数据放到表单的
POST
输出中呢?在元素上粘贴一个类,比如class=“theLink”,然后使用$(document)。在(“click”,“theLink”,function(e){$.POST(this.href,function(data){$(“#someContainer”).html(data);};}@VanquishedWombat我先试了一下,但没能成功。只是展示了一张空白的桌子。“转换为按钮”功能正在运行。谢谢你的帮助。我试过了,但是没有通过
POST
?我将代码更改为:
data=''+data+''
替代
是否有效?我会试试,但我对jquery不太在行。@Mike我认为输入不会有任何影响。你的权利,更改为输入没有帮助,它似乎只捕获了应该发送的内容的前10-20个字符。我试着这样做:
data=''
@Mike你设置了两次
属性。我知道了。必须将
value=\'+encodeURIComponent(行)+'\'>
更改为
value=“'+encodeURIComponent(行)+'>
.btn-as-link{
  border: none;
  outline: none;
  background: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}