How can I get DataTable with JQuery Post

How can I get DataTable with JQuery Post

loalvaresloalvares Posts: 2Questions: 0Answers: 0
edited November 2011 in General
Hi guys,

I am doing a JQuery Post to a page containg the DataTable. I need to bring the table using the innerHTML.:
document.getElementById('Div_Bsc').innerHTML=oXMLHttp.responseText;

The table works perfectly when I dont inner the page, but when I inner the page, the table doesn't work.

That's my code to inner the page containg the DataTable.

function MostraBsc(){
document.getElementById('select').style.visibility='hidden';
document.getElementById('Div_Bsc').style.visibility='visible';
var data_inicial = document.getElementById('data_inicio').value;
var data_final = document.getElementById('data_fim').value;
var dados = "dt_inicial="+data_inicial+"&dt_final="+data_final;
//alert(dados);
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", "monta_tabela_bsc.php", true);
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function(){
if(oXMLHttp.readyState == 4){
if(oXMLHttp.status == 200 || oXMLHttp.status == 304){
document.getElementById('Div_Bsc').innerHTML=oXMLHttp.responseText;
}else{
mensagem("Ocorreu erro: "+ oXMLHttp.statustext);
}
}
};
oXMLHttp.send(dados);
return false;
}

Any help will be appreciated.

Replies

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    edited November 2011
    [code]
    document.getElementById('Div_Bsc').innerHTML=oXMLHttp.responseText;
    $('#Div_Bsc').dataTable();
    [/code]

    should do it.

    Allan
This discussion has been closed.