Bonjour,
J'ai le code suivant.
Puis le fichier inputpostalcode.php:
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 <div class="form-group col-md-4"> <label for="Ville">Ville</label> <input list="city" id="city-choice" name="city-choice" class="form-control" /> <datalist id="city"> <select type="text" class="form-control client_ville" onchange="send_postalcode(this.value)"> <?php $list = $bdd->query('SELECT DISTINCT * FROM ville ORDER BY ville_nom ASC'); while ($data = $list->fetch()) { ?> <option value="<?php echo $data['ville_nom']; ?>"> <?php echo $data['ville_nom']; ?></option> <?php } $list->closeCursor(); ?> </select> </datalist> </div> <script> function send_postalcode(city_ref){ var city_ref = $(this).val(); var load_postalcode = $(this).find('.load_postalcode'); $.ajax({ url: "modal_header/Client/ajax/inputpostalcode.php", method: "POST", data: { city_ref: city_ref } }) .done(function( retour_html ) { load_postalcode.html( retour_html ); console.log( "success ajax client" ); }) .fail(function() { console.log( "error facture creation ajax" ); }); } </script>
Mon problème commence à la 1ère partie du code : je n'ai aucun console.log qui réponds dans ma console, ni celui du done ni celui du fail ( et bien sûr ma de requête post dans l'onglet réseau).
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 <?php include '../../../../Include/connect.php' ; $city_ref = (array_key_exists('city_ref', $_POST)) ? $_POST['city_ref']: NULL; if ($city_ref) { $stmt = $bdd->prepare(' SELECT * FROM client WHERE client_ville = :code '); $stmt->bindValue(':code', strtoupper($city_ref), PDO::PARAM_STR); $stmt->execute(); if ($donnees = $stmt->fetch(PDO::FETCH_ASSOC)) { ?> <input class="form-control client_codepostal_add" type="text" value="<?php echo $donnees['client_codepostal'] ?>" /> <?php } } ?>
Une idée? merci
Partager