如何重新加载数据表(jquery)数据? [英] How to reload the datatable(jquery) data?

查看:20
本文介绍了如何重新加载数据表(jquery)数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重新加载选定的标签?实际上我在重新加载部分时遇到了问题.当我添加我的数据时,我将成功保存在数据表中,但在数据库的 id 字段中,它显示了正确的 id,但是当我添加详细信息时,它没有在数据表中显示 id.

How to reload the selected tab? Actually I have problem with reloading part. When I add my data I'll successfully saved in datatable but in id field in database it shows proper id, but when I add the detail its not shows id in datatable.

(在刷新摘要选项卡之前)这里是示例,它在数据表 id 患者丈夫年龄 ........ 等等...

(before refresh the summary tab) here is example it shows something like this in datatable id patient husband age ...........so on... '' xyz abc 23....... so on...

(手动刷新后)但是当我刷新我的页面时它成功显示..在数据表中是这样的:id耐心丈夫年龄..........等等...... 13 xyz abc 23 ....... 等等...

(after refreshing manually) but when I refresh my page it show successfully..like this in datatable: id patient husband age ...........so on... 13 xyz abc 23 ....... so on...

但正是我想要的,当我添加详细信息时,它应该会自动刷新选定的选项卡.

But exactly I want when I add my detail it should automatically refresh the selected tab.

我的代码如下:

<button type="button"  a href="javascript:void(0);" onclick="fnClickAddRow();">Add Summary</button>

function fnClickAddRow(event) {

$('#table_scroll').dataTable().fnAddData( [

$('#patientt').val(),$('#husband').val(),$('#age').val(),$('#opu_no').val(),$('#date').val(),$('#proc').val(),$('#no_of_eggs').val(),$('#fert').val(),$('#et_date').val(),$('#et_day').val(),$('#et').val(),$('#fz').val(),$('#bioch_preg').val(),$('#clin_preg').val(),$('#fh').val(),$('#comment').val()

]);


var datastring = $(Form_summary).serialize();

$.ajax({
    type: "POST",
    url: "summaryajax.php",
    data: datastring, 
    success: function(response){

 alert(response);

    }
    });

我也厌倦了这种方法,但没有成功.

I also tired this approach but no success.

我希望我的数据表刷新数据

I want my datatable to refresh the data

function fnClickAddRow(event) {

var datastring = $(Form_summary).serialize();

$.ajax({
    type: "POST",
    url: "summaryajax.php",
    data: datastring, 
    success: function(response){
       $('#table_scroll').dataTable().fnAddData( 
          [resposne, $('#patientt').val(), $('#husband').val(),$('#age').val(),
            $('#opu_no').val(), $('#date').val(),$('#proc').val(), $('#no_of_eggs').val(), 
            $('#fert').val(),$('#et_date').val(), $('#et_day').val(), $('#et').val(), 
            $('#fz').val(), $('#bioch_preg').val(), $('#clin_preg').val(), $('#fh').val(), 
            $('#comment').val() ]);
    }
});

推荐答案

你可以用一个简单的方法...

You can use a simple approach...

$('YourDataTableID').dataTable()._fnAjaxUpdate();

它将通过使用相同参数发出ajax请求来刷新数据.很简单.

It will refresh the data by making an ajax request with the same parameters. Very simple.

这篇关于如何重新加载数据表(jquery)数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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