开发者

how to reload the selected tab jquery

how to reload the selected tab actually i having problem in 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.

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

(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 will automatically refresh the selected tab.

here is my code as below:

<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);

    }
    });


In your ajax success event, instead of alert add the below. It will load your tab.

$('tabSelector').tabs( "load" , indexOfYourDataTableTab )

But I think, you can just reload your datatable or update id column of that newly inserted row instead reloading the entire tab.

Otherwise, first post your data to PHP file & get newly inserted ID in response, then add row into data table

function fnClickAddRow(event) {

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

$.ajax({
    type: "POST",
    url: "summaryajax.php",
    data: datastring, 
    success: function(response){
       $('#table_scroll').dataTable().fnAddData( 
          [response, $('#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() ]);
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜