Blame view

frontend/web/js/script.js 1.18 KB
6748c345   Alexey Boroda   -Forms almost ready
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  $(
      function() {
          $(document)
              .on(
                  'beforeSubmit', '#feedback-form', function(e) {
                      var f = this;
                      var form = $(this);
                      var formData = form.serialize();
                      $.ajax(
                          {
                              url: form.attr("action"),
                              type: form.attr("method"),
                              data: formData,
                              success: function(data) {
                                  f.reset();
                                  $('#feedback-modal')
                                      .modal('hide');
                                  $('#success-modal')
                                      .modal('show');
                              },
                              error: function() {
                                  $('#feedback-modal')
                                      .modal('hide');
                              }
                          }
                      );
                  }
              )
              .on(
                  'submit', '#feedback-form', function(e) {
                      e.preventDefault();
                  }
              );
      }
  );