Bonjour

Je crée un tableau de données avec datatables (datatables.net). J'aimerai que toutes les x secondes, le contenu de mon tableau soit mis à jour d'après ma source AJAX.

J'ai essaie plusieurs combinaisons, mais sans succès. Par exemple, ce qui me paraissait le plus logique (mais ça ne marche pas) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function refresh() {
	oTable.fnReloadAjax(null,null,null,false);
}
 
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
	if ( typeof sNewSource != 'undefined' && sNewSource != null )
	{
		oSettings.sAjaxSource = sNewSource;
	}
	this.oApi._fnProcessingDisplay( oSettings, true );
	var that = this;
	var iStart = oSettings._iDisplayStart;
 
	oSettings.fnServerData( oSettings.sAjaxSource, [], function(json) {
		/* Clear the old information from the table */
		that.oApi._fnClearTable( oSettings );
 
		/* Got the data - add it to the table */
		var aData =  (oSettings.sAjaxDataProp !== "") ?
		that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
 
		for ( var i=0 ; i<aData.length ; i++ )
		{
			that.oApi._fnAddData( oSettings, aData[i] );
		}
 
		oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
		that.fnDraw();
 
		if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true )
		{
			oSettings._iDisplayStart = iStart;
			that.fnDraw( false );
		}
 
		that.oApi._fnProcessingDisplay( oSettings, false );
 
		/* Callback user function - for event handlers etc */
		if ( typeof fnCallback == 'function' && fnCallback != null )
		{
			fnCallback( oSettings );
		}
	}, oSettings );
 
}
 
// refresh
polling = setInterval(function() {
	refresh();
}, 1*1000); // refresh toutes les secondes
Auriez-vous une idée pour que j'arrive à mettre à jour les données à intervalles réguliers ?

Merci pour votre aide
flacdo