tchuss Posted January 9, 2017 Share Posted January 9, 2017 Bonjour, j'ai écris un code en javascript (une map google), lorsque la personne clic sur un marqueur je veux inscrire un résultat sur une table SQL...et je galère. Auriez-vous une idée ? Link to comment Share on other sites More sharing options...
Christophe Boix Posted January 13, 2017 Share Posted January 13, 2017 Bonjour, Dans la fonction de l'action au clic sur le marqueur, il faudrait rajouter une fonction $.ajax (regardez sur ajax-cart.php pour avoir des exemple, sinon dans mon exemple 1) qui ferait une requete pour poster des variables JS vers un fichier php que vous allez créerez pour faire la requete PHP (voir exemple2). Exemple 1 : requete AJAX dans un fichier JS $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(), async: true, cache: false, data: 'ajax_blockcart_display=expand' }); Exemple 2 : récupération des variables sur un fichier php include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../init.php'); if ( isset($_POST['ajax_blockcart_display']) || isset($_GET['ajax_blockcart_display'])) { $ajax_blockcart_display=$_GET['ajax_blockcart_display']; // echo $ajax_blockcart_display; /* requete SQL à faire ici */ } Bon courage Link to comment Share on other sites More sharing options...
tchuss Posted February 11, 2017 Author Share Posted February 11, 2017 Salut, et merci. J'ai pas eu d'alert me disant que quelqu'un avait répondu, désolé...j'avais oublié ce post, car trouvé une méthode un peu dans le même style, je passe par un formulaire pour stocker les infos, puis j'utilise ajax pour l'envoyer et je récupère donc en php les infos. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now