Applying Ajax but Datatables design not working
Applying Ajax but Datatables design not working
Hi Allan,
I have found this Ajax function to retrieve data without loading the page.
Here's the code:
function showUser(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","test.php?sample="+str,true);
xmlhttp.send();
}
I have successfully retrieved the data but the problem is that the datatables design won't work and also excel exporting.
$('#datatables1').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
},
"aoColumns": [
null,
null,
null,
null,
{"sType": "currency"},
null,
null,
null,
null,
{"sType": "currency"}
]
} );
What should I do?
Please need help.
Thanks,
Lester