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

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

问题描述

如何重新加载所选标签?其实我有重新加载的问题。当我添加我的数据时,我将成功保存在datatable中,但在数据库中的id字段中显示正确的id,但是当我添加其在datatable中不显示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.

(在刷新摘要选项卡之前)这里是一个例子,它在datatable id中显示这样的病人丈夫的年龄...........所以......xyz abc 23 .......所以...

(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...

(手动刷新),但是当我刷新我的页面,它显示成功...像这样在datatable:id耐心丈夫年龄..... ......等等... 13 xyz abc 23 ....... so ... ...

(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.

我希望我的datatable刷新数据

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.

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

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