Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.form').submit(function(e) {
- e.preventDefault();
- var $form = $(this),
- url = $form.attr('action'),
- data = $form.serialize(),
- ok = true,
- $inputs = $form.find('input:required');
- $inputs.each(function() {
- var $input = $(this);
- if (!$input.val()) {
- console.log('error');
- ok = false;
- }
- });
- if (ok) {
- return true;
- } else {
- return false;
- }
- $.ajax({
- type: 'POST',
- url: url,
- data: data,
- success: function(response) {
- $.magnificPopup.open({
- items: {
- src: '/thank-you.html'
- },
- type: 'ajax',
- closeBtnInside: false,
- }, 0);
- $('.form').hide();
- $('.side-block').hide();
- var delay = 7000;
- setTimeout(function() {
- window.location = '/home.html';
- }, delay);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement