Bonjour,

je rencontre actuellement un souci sur mon code, en effet la requete ajax semble figée,

Code de ma page
Code php : 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php require_once('../Connections/Extracteur.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}
 
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Extracteur de visuels</title>
<style type="text/css">
body {
	margin:0px;
	padding:0px;
	background-image:url(../extracteur/images/main-area-bg.png)
}
img {
	border:0px;
}
</style>
<script src="ajax_framework.js" language="javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Goudy+Bookletter+1911' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Signika+Negative:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Dosis:500' rel='stylesheet' type='text/css'>
<link href="../extracteur/css/style.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<table height="185" width="100%" border="0" cellpadding="0" cellspacing="0" background="../extracteur/images/top-bg3.png">
  <tr>
    <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
      <table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><a href="http://www.paritys.com"><img src="../extracteur/images/logo.png" width="280" height="65" alt="logo" /></a></td>
      </tr>
    </table></td>
  </tr>
</table>
<table height="24" width="100%" border="0" cellspacing="0" cellpadding="0" background="../extracteur/images/main-top-shadow.png">
  <tr>
    <td><?php echo $_SESSION['MM_Username']; ?>&nbsp;<?php echo $_SESSION['login']; ?></td>
  </tr>
</table>
<table width="900" border="0" align="center" cellpadding="10" cellspacing="0">
  <tr>
    <td><h1>Extracteur de visuels</h1></td>
  </tr>
</table>
<form id="recherche" name="recherche" method="get" action="articles.php">
  <table width="900" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td align="center" bgcolor="#FFFFFF">(Saisir une référence, une famille ou un début de libellé)</td>
    </tr>
    <tr>
      <td align="center" valign="middle" bgcolor="#FFFFFF"><input name="text" type="text" id="text" size="100" /></td>
    </tr>
  </table>
  <table width="900" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td align="center" bgcolor="#FFFFFF"><input type="submit" name="recherche" id="recherche" value="Lancer la recherche" /></td>
    </tr>
  </table>
</form>
<p><!-- Show Message for AJAX response -->
<div id="insert_response"></div></p>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>  <?
if(isset($_GET['text']) && $_GET['text'] != NULL) // on vérifie d'abord l'existence du POST et aussi si la requete n'est pas vide.
{
$requete = htmlspecialchars($_GET['text']); // on crée une variable $requete pour faciliter l'écriture de la requête SQL, mais aussi pour empêcher les éventuels malins qui utiliseraient du PHP ou du JS, avec la fonction htmlspecialchars().
 
mysql_select_db($database_Extracteur, $Extracteur);// on utilise la fonction mysql_num_rows pour compter les résultats pour vérifier par après
$query_Visuel = "SELECT *  FROM `articles` WHERE `Reference`='$requete' OR `Code_Famille`='$requete' OR `Code_gencod`='$requete' OR `Libelle_Famille` LIKE '%$requete%' OR `Libelle_article` LIKE '%$requete%'";
$Visuel = mysql_query($query_Visuel, $Extracteur) or die(mysql_error());
$row_Visuel = mysql_fetch_assoc($Visuel);
$totalRows_Visuel = mysql_num_rows($Visuel);
 
 
if($totalRows_Visuel != 0) // si le nombre de résultats est supérieur à 0, on continue
{
// maintenant, on va afficher les résultats et la page qui les donne ainsi que leur nombre, avec un peu de code HTML pour faciliter la tâche.
?>
<h3>Résultats de votre recherche.</h3>
<p>Nous avons trouvé <? echo $totalRows_Visuel;  // on affiche le nombre de résultats 
if($totalRows_Visuel > 1) { echo ' résultats'; } else { echo ' résultat'; } // on vérifie le nombre de résultats pour orthographier correctement. 
?>
  dans notre base de données. Voici les articles que nous avons trouvés :<br/>
 <br/>
<form id="articles" name="articles" method="GET" action="javascript:insert()" >
<table width="100%" border="0" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF">
<?php do { ?>
 
<tr onClick="<?php echo $filename; ?>', target='_blank'; " onMouseOver="this.style.cursor='hand'; this.bgColor = '#F4777D'; " onmouseout ="this.bgColor = 'FFFFFF'">
 	<td>
<br/><?php echo $row_Visuel['Code_article']; ?><input name="article" type="text" id="<?php echo $row_Visuel['Code_article']; ?>" value="<?php echo $row_Visuel['Code_article']; ?>" /><input name="login" type="text" id="<?php echo $_SESSION['login']; ?>" value="<?php echo $_SESSION['login']; ?>" />
	</td>
 	<td><?php echo $row_Visuel['Libelle_article']; ?><input name="libelle" type="text" id="<?php echo $row_Visuel['Libelle_article']; ?>" value="<?php echo $row_Visuel['Libelle_article']; ?>" /></td>
    <td><? echo $row_Visuel['Code_Famille']; ?><input name="famille" type="text" id="<? echo $row_Visuel['Code_Famille']; ?>" value="<? echo $row_Visuel['Code_Famille']; ?>" /></td>
    <td><? echo $row_Visuel['Code_gencod']; ?><input name="gencod" type="text" id="<? echo $row_Visuel['Code_gencod']; ?>" value="<? echo $row_Visuel['Code_gencod']; ?>" /></td>
    <td>
   <?php
$filename = '../visuels/'.$row_Visuel['Code_gencod'].'.jpg';	
 
	if (file_exists($filename)) {
   	 include('visuel.php');
	} else {
    echo "aucun visuel disponible.";
}
?>  
     </td>
   <td>
       <input type="submit" name="boutoninsert" id="boutoninsert" value="Ajouter au panier" />
       </td>
 
</tr> 
 
<?php } while ($row_Visuel = mysql_fetch_assoc($Visuel)); ?>
</table> 
 </form>
<br/>
<br/>
</p>
<?
} // Fini d'afficher les résultats ! Maintenant, nous allons afficher l'éventuelle erreur en cas d'échec de recherche et le formulaire.
else
{ // de nouveau, un peu de HTML
?>
<h3>Pas de résultats</h3>
<p>Nous n'avons trouvé aucun résultat pour votre requête "<? echo $_POST['test']; ?>". <a href="../extracteur/rechercher-groupe.php">Réessayez</a> avec autre chose.</p>
<?
}// Fini d'afficher l'erreur ^^
mysql_close(); // on ferme mysql, on n'en a plus besoin
}
else
{ // et voilà le formulaire, en HTML de nouveau !
?>
<?
}
// et voilà, c'est fini !
?>
<!--<p><a href="csv.php?text=<?php /*?><? echo $_GET['text']; ?><?php */?>">Créer un fichier csv</a></p>-->
<p>Nouvelle recherche</p>
<form id="recherche" name="recherche" method="get" action="articles.php">
  <table width="900" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td align="center" bgcolor="#FFFFFF">(Saisir une référence, une famille ou un début de libellé)</td>
    </tr>
    <tr>
      <td align="center" valign="middle" bgcolor="#FFFFFF"><input name="text" type="text" id="text" size="100" /></td>
    </tr>
  </table>
  <table width="900" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td align="center" bgcolor="#FFFFFF"><input type="submit" name="recherche" id="recherche" value="Lancer la recherche" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
 
          <p>&nbsp;</p>
          <h2>&nbsp;</h2></td>
      </tr>
    </table></td>
  </tr>
</table>
 
</body>
</html>
<?php
mysql_free_result($Visuel);
?>

Code de mon fichier js
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
/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
 
var http = createObject();
 
 
/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Veuillez patienter..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var article= document.getElementById('article').value;
var login= document.getElementById('login').value;
var panier = document.getElementById('panier').value;
var libelle = document.getElementById('libelle').value;
var famille = document.getElementById('famille').value;
var gencod = document.getElementById('gencod').value;
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?article='+article+'&login=' +login+'&panier=' +panier+'&libelle=' +libelle+' &famille=' +famille+' &gencod=' +gencod+' &nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){ 
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('insert_response').innerHTML = 'Article ajouté:'+response;
}
}
Code de mon fichier insert.php
Code php : 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
52
53
54
55
56
57
58
59
<?php require_once('../Connections/Extracteur.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$article= $_GET['article'];
$login= $_GET['login'];
$panier= $_SESSION['panier'];
$libelle= $_GET['libelle'];
$famille= $_GET['famille'];
$gencod= $_GET['gencod'];
 
 
$insertSQL = sprintf("INSERT INTO panier (Login, Code_Article, Nom_Panier, Code_Famille, Libelle_Article, Code_gencod) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($login, "int"),
                       GetSQLValueString($article, "text"),
                       GetSQLValueString($panier, "text"),
                       GetSQLValueString($famille, "text"),
					   GetSQLValueString($libelle, "text"),
					   GetSQLValueString($gencod, "text")
					   );
 
mysql_select_db($database_Extracteur, $Extracteur);
  $Result1 = mysql_query($insertSQL, $Extracteur) or die(mysql_error());
 
 
 
/*If is set URL variables and insert is ok, show the site name */
echo $article;
 
?>

Lorsque je clique sur le bouton ajouter l'article, le script laisse afficher Veuillez patienter... sans mettre Article Ajouté.

Merci par avance pour votre aide.

KryO91