Advertisement
Guest User

Untitled

a guest
May 31st, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. $('.form').submit(function(e) {
  2. e.preventDefault();
  3.  
  4. var $form = $(this),
  5. url = $form.attr('action'),
  6. data = $form.serialize(),
  7. ok = true,
  8. $inputs = $form.find('input:required');
  9.  
  10. $inputs.each(function() {
  11. var $input = $(this);
  12. if (!$input.val()) {
  13. console.log('error');
  14. ok = false;
  15. }
  16. });
  17.  
  18. if (ok) {
  19. return true;
  20. } else {
  21. return false;
  22. }
  23.  
  24. $.ajax({
  25. type: 'POST',
  26. url: url,
  27. data: data,
  28. success: function(response) {
  29. $.magnificPopup.open({
  30. items: {
  31. src: '/thank-you.html'
  32. },
  33. type: 'ajax',
  34. closeBtnInside: false,
  35.  
  36.  
  37. }, 0);
  38. $('.form').hide();
  39. $('.side-block').hide();
  40.  
  41. var delay = 7000;
  42. setTimeout(function() {
  43. window.location = '/home.html';
  44. }, delay);
  45.  
  46. }
  47.  
  48.  
  49.  
  50.  
  51. });
  52.  
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement