Bonjour,

je suis débutant en Jquery et j'essaie de mettre en place n formulaires d'upload en jquery sur la même page.

Par exemple :
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
<form id="form1" name="form" action="" method="POST" enctype="multipart/form-data">
	<img name="loading" src="loading.gif" style="display:none;">
	<input id="fileToUpload" type="file" size="45" name="fileToUpload" class="input">
	<button class="button" id="buttonUpload" onclick="return ajaxFileUpload();">Envoyer</button>
</form>
 
<form id="form2" name="form" action="" method="POST" enctype="multipart/form-data">
	<img name="loading" src="loading.gif" style="display:none;">
	<input id="fileToUpload" type="file" size="45" name="fileToUpload" class="input">
	<button class="button" id="buttonUpload" onclick="return ajaxFileUpload();">Envoyer</button>
</form>
 
<form id="form3" name="form" action="" method="POST" enctype="multipart/form-data">
	<img name="loading" src="loading.gif" style="display:none;">
	<input id="fileToUpload" type="file" size="45" name="fileToUpload" class="input">
	<button class="button" id="buttonUpload" onclick="return ajaxFileUpload();">Envoyer</button>
</form>
Mon 1er souci (et peut être le seul) est de savoir quel formulaire a été validé, voici le JS (que j'ai récupéré d'un script AjaxFileUploader) qui fonctionne pour un seul formulaire :

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
<script type="text/javascript">
	function ajaxFileUpload()
	{
		$("loading")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});
 
		$.ajaxFileUpload
		(
			{
				url:'AjaxFileUploader/doajaxfileupload.php',
				secureuri:false,
				fileElementId:'fileToUpload',
				dataType: 'json',
				data:{name:'logan', id:'id'},
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							alert(data.error);
						}else
						{
							alert(data.msg);
						}
					}
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			}
		)
 
		return false;
 
	}
	</script>
Quel est la commande pour savoir quel id de formulaire a été cliqué ?

Merci