Bonjour à tous,
J'ai une fonction qui marche tres bien en AJAX et je voudrais rajouter un gif pour faire patienter avant le resultat de ma requete.
voila ma fonction
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
 
function requete(page,select,form,target,target1,target2,target3,target4)
{
	getXhr();
 
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4)
		{		
		if(xhr.status == 200 || xhr.status == 304)
			eval(xhr.responseText);
		}
	};
	xhr.open("POST",page,true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send("form="+escape(form)+"&type="+escape(select.id)+"&id="+escape(select.value)+"&target="+escape(target)+"&target1="+escape(target1)+"&target2="+escape(target2)+"&target3="+escape(target3)+"&target4="+escape(target4));
}
J'ai essayé cà mais ca 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
function requete(page,select,form,target,target1,target2,target3,target4)
{
	getXhr();
	
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState < 4)
		{
		xhr.responseText = '<p><center><img src="gifs/wait.gif" alt="Patientez!" /></center></p>';
		}
		if(xhr.readyState == 4)
		{		
		if(xhr.status == 200 || xhr.status == 304)
			eval(xhr.responseText);
		}
		else
		{

	};
	
	xhr.open("POST",page,true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send("form="+escape(form)+"&type="+escape(select.id)+"&id="+escape(select.value)+"&target="+escape(target)+"&target1="+escape(target1)+"&target2="+escape(target2)+"&target3="+escape(target3)+"&target4="+escape(target4));
}
mais ca ne marche pas quelqu'un aurait une idée?
Merci d'avance