WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] need a confirmation text to appear on email submission (5 posts)

  1. southcast
    Member
    Posted 1 year ago #

    I have somehow put together a code which allows the users to send me a list of selected posts via e-mail and it is working fine.

    Now, I would like a confirmation text eg. 'THANK YOU' appear to the user, once user has clicked the "send email" button. This could appear below the submit button and could have a class so that I could make it a bit pretty using css. I hope this can be achieved with appropriate changes in my codes. Please suggest a correction.

    My javascript looks like this :

    $(document).ready(function(){
    
      $('#sendEmail').click(function(){
         $.ajax({
             type: 'POST',
             url: 'www.example.com/email.php',
             data: { content: $('#email-data').html()}
         });
      });
    
    });

    and my HTML looks like this :

    <div id="email-data">
        <div id="content">
            some php generated content
        </div>
    </div>
    <a id="sendEmail"> SEND EMAIL</a>

    my email.php looks like this

    <?php
    
      $to = "someone@somemail.com";
      $subject = "FROM WEBSITE";
      $message = $_POST['content'];
      $headers = "From: company <someotherguy@somecompany.in>" . "\r\n" .
                 "Content-type: text/html" . "\r\n";
      mail($to, $subject, $message, $headers);
    ?>

    Please let me know if I am not clear enough.

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Link to your website with the issue, please.

  3. southcast
    Member
    Posted 1 year ago #

    @andrew It is in a developement stage, i will put the site out of maintenance model for your observation for a while. Please take a look.

    Click here is the page in question

  4. southcast
    Member
    Posted 1 year ago #

    @andrew I have put a link to the page in question. Thanks.

  5. southcast
    Member
    Posted 1 year ago #

    Solved it. Will leave a response here in case it could help someone. It just needed a little tweak. Now my JS looks like this.

    <script type="text/javascript">
    jQuery(document).ready(function($) {
        $('#sendEmail').click(function(){
                 $.ajax({
                     type: 'POST',
                     url: 'http://xxxxxxxxxxxxxxx/email.php',
                     data: { content: $('#email-data').html()},
                     success:function(data) {
                            alert('You data has been successfully e-mailed');
                    }
               });
         });
    });
    </script>

Topic Closed

This topic has been closed to new replies.

About this Topic