I use a form to get the email adress that will be recorded for the newsletter of my site. this form is managed by AJAX send and get the response :
$.ajax({
        url: "./control/newsletter/ct_newsletter_subscribe.php",
        type: "POST",
        data: $this.serialize(),
        success: function(html) {
            alert(html); // html contient l'id du dernier inscrit
            if(html == 'erreur'){
                var message = "<p>Erreur d'enregistrement en BDD</p>";
            }else if(html != 'erreur'){
                var message = "Adresse email enregistrée en BDD : id = "+html;
            }
I want the response (that get the lastInsertId) to be used in a second function to get the informations recorded.
In the file ct_newsletter_subscribe.php I get the lastInsertId but I cannot re-use it.
        $LastInsertId = add_email_newsletter($newsletterNom, $newsletterPrenom, $newsletterEmail, $newsletterGsm, $registered, $regdate, $codeConfirm);
        echo '<script>alert("ct newsletter subscribe L36 : '.$LastInsertId.'")</script>';// DEBUG
        $reponse = $LastInsertId;
        echo '<script>alert("ct newsletter subscribe L38 : '.$reponse.'")</script>';// DEBUG
In this part, $reponse and $LastInsertId contain the last id, but I cannot re-use it for another function. the 2 "echo ..." doesn't give the variable I want them to show I don't understand why.
 
    