Datatables and AJAX

Datatables and AJAX

Super_carotteSuper_carotte Posts: 11Questions: 1Answers: 0
edited November 2013 in General
Hello everyone :)

I have some trouble to use datatables with AJAX.

I found this :http://datatables.net/examples/data_sources/ajax.html
But it didn't help me a lot.

My problem is that when i select a value in a , i would like to make a datatable apear.
It works, i have the data but not the "look" of datatable.

Do one of you have an exemple of code where a select makes apear a datatables?

Thank you,
Benjamin.

If this can help, here are the important parts of my code:
index.php:
<!-- Les JS Datatables -->




<!-- Code pour parametrer Datatables -->

$(document).ready( function () {
$('#showJob').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 3, "desc" ]],
"sDom": '<"H"lfrT>t<"F"ip>',
"oTableTools": {
"sSwfPath": "libs/datatables/copy_csv_xls_pdf.swf",
"aButtons": [
"copy", "csv", "xls", "pdf",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
}
} );
} );

<!-- Fin Code pour parametrer Datatables -->

<!-- AJAX -->

function go(){
var xhr = getXhr()
// On défini ce qu'on va faire quand on aura la réponse
xhr.onreadystatechange = function(){
// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
if(xhr.readyState == 4 && xhr.status == 200){
leselect = xhr.responseText;
// On se sert de innerHTML pour rajouter les options a la liste
document.getElementById('livre').innerHTML = leselect;
}
}
// Ici on va voir comment faire du post
xhr.open("POST","controleurs/rapportConstatatifSecondaire.php",true);
// ne pas oublier ça pour le post alert('5');
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
// ne pas oublier de poster les arguments
// ici, l'id de l'auteur
sel = document.getElementById('zoom_appli');
//alert('sel='+sel);
idauteur = sel.options[sel.selectedIndex].value;
date1 = document.getElementById('date_little_combo').value;
xhr.send("date1="+date1+"&zoom_appli="+idauteur);
}


<!-- HTML -->




Zoom:

<?php
$list_deroul_zoom = "";

foreach($list_appli as $appli)
{
$list_deroul_zoom .= "".$appli['nom']."";
}
$list_deroul_zoom .= "";
echo $list_deroul_zoom;
?>











file rapportConstatatifSecondaire.php:
$datatables= retour_donnees_format_datatablest("objAppli", $id_appli, $date1);
echo $datatables;
This discussion has been closed.