Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <form action="" method="post" id="embedded-subscribe-form" name="boscoSubscribe" class="form-group form-inline">
  2. <input type="email" value="" name="email" class="form-control bosco-form navigation-footer-email-signup-input required email" placeholder="Email Address" id="email">
  3. <button type="submit" name="subscribe" id="embedded-subscribe" class="btn btn-default bosco-button-highlight navigation-footer-email-signup-button"></button>
  4. <div class="throw_error"></div>
  5. <div id="success"></div>
  6. </form>
  7.  
  8. <script type="text/javascript">
  9. jQuery(document).ready(function($) {
  10. $('#embedded-subscribe-form').on("submit", "form", function(event) {
  11. event.preventDefault();
  12. $('#email + .throw_error').empty();
  13. $('#success').empty();
  14.  
  15. // Validate fields if required using jQuery
  16.  
  17. var boscoSubscribe = { //Fetch form data
  18. 'email' : $('input[email=email]').val()
  19. };
  20.  
  21. $.ajax({
  22. type : 'POST',
  23. url : 'process-email.php',
  24. data : boscoSubscribe,
  25. dataType : 'multipart/form-data',
  26. success : function(data) {
  27. if (!data.success) {
  28. if (data.errors.name) {
  29. $('.throw_error').fadeIn(500).html(data.errors.email);
  30. }
  31. }
  32. else {
  33. $('#success').fadeIn(500).append('<p>' + data.posted + '</p>');
  34. }
  35. }
  36. });
  37.  
  38. return false;
  39. });
  40. });
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement