ça fonctionne ... presque
avec le header location de mon fichier php , ça renvois tout le code en réponse.
Si je retire le header curieusement, l'appuie sur le bouton ne fait rien en apparence mais si je raffraichi la page il supprime le bon enregistrement.
Mieux encore, si je clic sur plusieurs, c'est retenu car le raffraichissement les supprimes tous.
Mon Dieu que c'est plus facile rien qu'en php lol.
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 <?php //function traitement($donnee_post){ // return print_r($donnee_post,true); //} //echo traitement($_POST); try { $bdd = new PDO('mysql:host=localhost;dbname=IFPipe;charset=utf8','root',''); } catch(Exception $e) { die('Erreur :' .$e->getMessage()); } $req = $bdd->prepare('DELETE FROM tbl_proposals WHERE id=:id'); $req->bindParam(':id', $_POST['idReceive']); $req->execute(); $req->closeCursor(); header('Location: cmdList.php'); ?>
Celui là quand il va tourner je vais l'encadrer pfff
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 <th class="text-center">Action</th> </tr> <?php while($data = $req->fetch()) { ?> <tr> <td class="pt-3-half" contenteditable="true"><?php echo htmlspecialchars($data['id']);?></td> <td class="pt-3-half" contenteditable="true"><?php echo htmlspecialchars($data['num_cmd']);?></td> <td class="pt-3-half" contenteditable="true"><?php echo htmlspecialchars($data['title']);?></td> <td class="pt-3-half" contenteditable="true">xxx</td> <td class="pt-3-half" contenteditable="true">xxx</td> <td class="pt-3-half"> xxx </td> <td><span class="label label-important">Pas Ok</span></td> <td> <div class="buttonInline"> <button class="btn-delete" data-id="<?php echo($data['id']);?>"> <i class="fa fa-times"></i> </button> </div> </td> <?php } $req->closeCursor();?> </tr> </table> <!-- <input type="button" id="ajax" value="Test Ajax" /><br> <p>Résultats de l'appel ajax:</p> <textarea id="results"></textarea> --> </div> </div> </div> </main> <script> $(function() { $('.btn-delete').click(function() { var idReceive = $(this).data('id'); // var idAjax=$("#ajax").val(); $.ajax({ url: "cmdDelete.php", method: "POST", data: 'idReceive='+idReceive, dataType: "html", success: function(msg){ $('#results').val(msg); } }); }); }); </script>
Partager