Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS for contact form #6

Open
kiwiot opened this issue Mar 8, 2016 · 0 comments
Open

JS for contact form #6

kiwiot opened this issue Mar 8, 2016 · 0 comments

Comments

@kiwiot
Copy link

kiwiot commented Mar 8, 2016

the JS for the form to be passed via AJAX is not attached to the theme.

init.js

`/----------------------------------------------------/
/* contact form
------------------------------------------------------*/

$('form#contactForm button.submit').click(function() {

  $('#image-loader').fadeIn();

  var contactName = $('#contactForm #contactName').val();
  var contactEmail = $('#contactForm #contactEmail').val();
  var contactSubject = $('#contactForm #contactSubject').val();
  var contactMessage = $('#contactForm #contactMessage').val();

  var data = 'contactName=' + contactName + '&contactEmail=' + contactEmail +
           '&contactSubject=' + contactSubject + '&contactMessage=' + contactMessage;

  $.ajax({

      type: "POST",
      url: "inc/sendEmail.php",
      data: data,
      success: function(msg) {

        // Message was sent
        if (msg == 'OK') {
           $('#image-loader').fadeOut();
           $('#message-warning').hide();
           $('#contactForm').fadeOut();
           $('#message-success').fadeIn();
        }
        // There was an error
        else {
           $('#image-loader').fadeOut();
           $('#message-warning').html(msg);
            $('#message-warning').fadeIn();
        }

      }

  });
  return false;

});`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant