Bonjour,

Je développe un gadget pour vista, seulement la récupération des infos sur le serveur distant ne fonctionne pas o_O .

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
var i = 0; // DEBUG

function update()
{
	var xhr;
	if ( window.XMLHttpRequest ) xhr = new XMLHttpRequest();
	else if ( window.ActiveXObject ) xhr = new ActiveXObject( 'Microsoft.XMLHTTP' );
	else
	{
		alert( 'JavaScript : votre navigateur ne supporte pas les objets XMLHttpRequest...' );
		return;
	}
	xhr.open( 'GET', 'http://www.serveurdistant.fr/page.php', true );
	xhr.onreadystatechange = function()
	{
		if ( xhr.readyState == 4 )
		{
			if( xhr.responseText.indexOf( '<comments_requireValidation>0</comments_requireValidation>' ) == -1 )
				document.getElementById( 'comments' ).style.backgroundImage = 'url( \'background-top.png\' )';
			else
				document.getElementById( 'comments' ).style.backgroundImage = 'url( \'none-top.png\' )';
				
			if( xhr.responseText.indexOf( '<friends_requireValidation>0</friends_requireValidation>' ) == -1 )
				document.getElementById( 'friends' ).style.backgroundImage = 'url( \'background-bottom.png\' )';
			else
				document.getElementById( 'friends' ).style.backgroundImage = 'url( \'none-bottom.png\' )';
			
			i++; // DEBUG
			document.getElementById( 'comments' ).innerHTML = i; // DEBUG
			document.getElementById( 'friends' ).innerHTML = xhr.responseText; // DEBUG
		}
	}
        xhr.send( '' );

	setTimeout( update, 30000 );
}
Et une partie du html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
... <body onLoad="update()"> ...

Donc le champs 'comments' s'incrémente bien et le champs 'friends' prend une valeur de la page récupéré mais pas la bonne ...

Je ne vois pas pourquoi il ne récupère pas la bonne valeur dans xhr.responseText


Merci d'avance


Problème résolu