Bonjour à tous,
Je poste ce sujet car j'aimerais que mon panier qui ce trouve sur cette page ( http://kingdomoffreedom.crystal-serv.com/boutique.php ) s'actualise à chaque clique des liens "ajouter au minecart" sans recharger la page. J'ai vu qu'il y avait possibilité de pouvoir y faire en AJAX, car j'ai trouver un exemple sur un site qui permettait d'aller chercher une page html puis de l'actualiser or mon panier comporte du php :/
Voici le code entier de ma page :
En espérant avoir été clair, je vous remercie d'avance pour votre aide.
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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577 <!DOCTYPE html> <html lang="fr"> <head> <title>Boutique Kingdom Of Freedom !</title> <link rel="stylesheet" type="text/css" href="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/css_boutique.css"/> <script src="http://code.jquery.com/jquery-latest.js"></script> <link rel="icon" type="image/png" href="http://kingdomoffreedom.crystal-serv.com/fichier_global/favicon.png"/> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="Author" content="CrazyTermi"/> <meta http-equiv="Content-Style-Type" content="text/css"> <script type="text/javascript"> $(document).ready(function() { $('#slickbox').hide(); $('#slick-show').click(function() { $('#slickbox').show('slow'); return false; }); $(document).keydown(function() { if (event.keyCode == 27) { $('#slickbox').hide('fast'); return false; } }); $('#slick-hide').click(function() { $('#slickbox').hide('fast'); return false; }); $('#slick-toggle').click(function() { $('#slickbox').toggle(400); return false; }); }); $(document).ready(function() { $('#slickbox-2').hide(); $('#slick-show-2').click(function() { $('#slickbox-2').show('slow'); return false; }); $(document).keydown(function() { if (event.keyCode == 27) { $('#slickbox-2').hide('fast'); return false; } }); $('#slick-hide-2').click(function() { $('#slickbox-2').hide('fast'); return false; }); $('#slick-toggle-2').click(function() { $('#slickbox-2').toggle(400); return false; }); }); </script> <?php session_start(); include_once("fonctions-panier.php"); $erreur = false; $action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ; if($action !== null) { if(!in_array($action,array('ajout', 'suppression', 'refresh'))) $erreur=true; //récuperation des variables en POST ou GET $l = (isset($_POST['l'])? $_POST['l']: (isset($_GET['l'])? $_GET['l']:null )) ; $p = (isset($_POST['p'])? $_POST['p']: (isset($_GET['p'])? $_GET['p']:null )) ; $q = (isset($_POST['q'])? $_POST['q']: (isset($_GET['q'])? $_GET['q']:null )) ; //Suppression des espaces verticaux $l = preg_replace('#\v#', '',$l); //On verifie que $p soit un float $p = floatval($p); //On traite $q qui peut etre un entier simple ou un tableau d'entier if (is_array($q)){ $QteArticle = array(); $i=0; foreach ($q as $contenu){ $QteArticle[$i++] = intval($contenu); } } else $q = intval($q); } if (!$erreur){ switch($action){ Case "ajout": ajouterArticle($l,$q,$p); break; Case "suppression": supprimerArticle($l); break; Case "refresh" : for ($i = 0 ; $i < count($QteArticle) ; $i++) { modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i])); } break; Default: break; } } ?> </head> <body class='body_principal'> <div> <div class="div_bouton_positionnement_haut"> <br /> <p> <a class="bouton_acceuil" href="http://kingdomoffreedom.crystal-serv.com/"> Acceuil </a> <a class="bouton_haut" href="#" id="slick-show"> -<u>Achat avec des Izzis</u>- </a> <a class="bouton_haut" href="#" id="slick-show-2"> -<u>Achat avec des Euros</u>- </a> </p> </div> <div id="slickbox" class="div_cache"> <a class="btn_close" href="#" id="slick-hide">X</a> <br /> <div class="dimention_table_izzis"> <table class="table_izzis"> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Roche</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/roche.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de roche.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Pierre</b></u></span> <br /> <span class="prix_boutique_izzis">0.4 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/pierre.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de pierre.&q=1&p=0.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Terre</b></u></span> <br /> <span class="prix_boutique_izzis">0.4 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/terre.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de terre.&q=1&p=0.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Herbe</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/grass.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack d'herbe.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Minerais de diamant</b></u></span> <br /> <span class="prix_boutique_izzis">24,8 Izzis les 16 minerais !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/minerais_diamant.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 minerais de diamant.&q=1&p=24.8">Ajouter au Minecart !</a> </p> </td> </tr> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Minerais d'émeraude</b></u></span> <br /> <span class="prix_boutique_izzis">28,4 Izzis les 16 minerais !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/minerais_emeraude.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 minerais d'émeraude.&q=1&p=28.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Block de diamant</b></u></span> <br /> <span class="prix_boutique_izzis">14 Izzis le block !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/block_diamant.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 blocks de diamant.&q=1&p=14">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Block d'émeraude</b></u></span> <br /> <span class="prix_boutique_izzis">16 Izzis le block !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/block_emeraude.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 blocks d'émeraude.&q=1&p=16">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Diamant</b></u></span> <br /> <span class="prix_boutique_izzis">24.9 Izzis les 16 diamants !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/diamant.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 diamants.&q=1&p=24.9">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Emeraude</b></u></span> <br /> <span class="prix_boutique_izzis">28.4 Izzis les 16 émeraudes !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/emeraude.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 émeraudes.&q=1&p=28.4">Ajouter au Minecart !</a> </p> </td> </tr> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Planche de chène</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_chene.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches de chènes.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Planches de sapin</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_sapin.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches de sapin.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Planche de bouleau</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_bouleau.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches de bouleau.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Planche d'acajou</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_acajou.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches d'acajou.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Planche d'acacia</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_acacia.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches d'acacia.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> </tr> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Planche de chène noir</b></u></span> <br /> <span class="prix_boutique_izzis">0.6 Izzis les 32 planches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/planche_chene-noir.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 planches d'acacia.&q=1&p=0.6">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche de chène</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_chene.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches de chène.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche de sapin</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_sapin.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches de sapin.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche de bouleau</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_bouleau.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches de bouleau.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche d'acajou</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_acajou.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches d'acajou'.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> </tr> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche d'acacia</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_acacia.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches d'acacia'.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Buche de chène noir</b></u></span> <br /> <span class="prix_boutique_izzis">2.4 Izzis les 32 buches !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/buche_chene-noir.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=32 buches de chène noir.&q=1&p=2.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Podzol</b></u></span> <br /> <span class="prix_boutique_izzis">1 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/podzol.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de podzol.&q=1&p=1">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Sable</b></u></span> <br /> <span class="prix_boutique_izzis">0.4 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/sable.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de sable.&q=1&p=0.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Sable rouge</b></u></span> <br /> <span class="prix_boutique_izzis">0.4 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/sable_rouge.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de sable rouge.&q=1&p=0.4">Ajouter au Minecart !</a> </p> </td> </tr> <tr> <td> <p> <span class="titre_boutique_izzis"><u><b>Gravier</b></u></span> <br /> <span class="prix_boutique_izzis">0.4 Izzis le stack !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/sable_rouge.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 stack de gravier.&q=1&p=0.4">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Minerais d'or</b></u></span> <br /> <span class="prix_boutique_izzis">17.8 Izzis les 16 minerais !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/minerais_or.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 blocks de minerais d'or.&q=1&p=17.8">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Minerais de fer</b></u></span> <br /> <span class="prix_boutique_izzis">14.2 Izzis les 16 minerais !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/minerais_fer.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 blocks de minerais de fer.&q=1&p=14.2">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Minerais de charbon</b></u></span> <br /> <span class="prix_boutique_izzis">7.1 Izzis les 16 minerais !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/minerais_charbon.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=16 blocks de minerais de charbon.&q=1&p=7.1">Ajouter au Minecart !</a> </p> </td> <td> <p> <span class="titre_boutique_izzis"><u><b>Eponge</b></u></span> <br /> <span class="prix_boutique_izzis">14 Izzis l'éponge !</span> <br /><br /> <img src="http://kingdomoffreedom.crystal-serv.com/fichier_global/boutique/eponge.png" class="image_boutique"> <br /><br /> <a href="boutique.php?action=ajout&l=1 éponge.&q=1&p=14">Ajouter au Minecart !</a> </p> </td> </tr> </table> </div> <br /><br /><br /> <div class="dimention_table_panier"> <form method="post" action="boutique.php"> <table class="table_panier"> <tr> <td colspan="4"> <p> <h2><u><b>Minecart</b></u></h2> </p> </td> </tr> <tr> <td class="encadrement_sous-titre_panier"> <p> <span class="sous-titre_panier">Nom du produit</span> </p> </td> <td class="encadrement_sous-titre_panier"> <p> <span class="sous-titre_panier">Quantité</span> </p> </td> <td class="encadrement_sous-titre_panier"> <p> <span class="sous-titre_panier">Prix unitaire</span> </p> </td> <td class="encadrement_sous-titre_panier"> <p> <span class="sous-titre_panier">Supprimer</span> </p> </td> </tr> <?php if (creationPanier()) { $nbArticles=count($_SESSION['panier']['libelleProduit']); if ($nbArticles <= 0) { echo "<tr><td colspan=\"4\" class=\"texte_panier\"><b>Le minecart est vide !</b></td></tr>"; } else { for ($i=0 ;$i < $nbArticles ; $i++) { echo " <tr> <td> <p> <span>".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</span> </p> </td> <td> <p> <input class=\"quantite_panier\" type=\"text\" size=\"4\" name=\"q[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/> </p> </td> <td> <p> <span>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i])." Izzis</span> </p> </td> <td> <p> <a href=\"".htmlspecialchars("boutique.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\" class=\"btn_supprimer_panier\">X</a> <br /> </p> </td> </tr> "; } echo " <tr> <td colspan=\"4\"> <span>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> </td> </tr> <tr> <td></td><td></td><td></td> <td> <p> <span class=\"texte_panier\"><b>Total : ".MontantGlobal()." Izzis</b></span> <br /> <input type=\"submit\" value=\" Actualiser \" class=\"bouton_actualiser_panier\"/> <input type=\"hidden\" name=\"action\" value=\"refresh\"/> </p> </td> </tr> "; } } ?> </table> </form> </div> <br /> </div> <div id="slickbox-2" class="div_cache"> <a class="btn_close" href="#" id="slick-hide-2">X</a> <p> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><h3>A venir</h3><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </p> </div> </div> </body> </html>
Cordialement,
CrazyTermi.
Partager