PageSourceSearch

https://zs-knife.ru/modules/feedback/js/ajax_form.js

js zs-knife.ru collected 2026-10-08 14:31:48 UTC 2,448 bytes, 84 lines download raw bytes

1$('body').on('submit', 'form.ajax', function() {
2
3    var form = this
4
5    var formName = this.dataset.form
6
7    var formData = new FormData($(this)[0]);
8
9    $('input[type=submit]', form).data('defaultValue', $('input[type=submit]', form).val())
10    $('input[type=submit]', form).val('Пожалуйста, подождите...').prop('disabled', true)
11    if ($('#loading').length > 0) {
12        $('#loading').show()
13    }
14
15    $.ajax({
16        url: $(form).attr('action'),
17        type: 'post',
18        data: formData,
19        dataType: 'json',
20        cache: false,
21        contentType: false,
22        processData: false,
23        beforeSend: function() {
24            $('ul.errors', form).remove()
25        },
26        success: function(data) {
27            if ('message' in data) {
28
29
30
31
32                // fancybox
33                /*$.fancybox.close()
34                $.fancybox([
35                    { href : '#thanks' }
36                ]);*/
37
38
39                // bootstrap
40                var visibleModal = $('.modal.show').attr('id');
41                if (visibleModal) {
42                    $('#' + visibleModal).modal('hide');
43                }
44                $('.modal-message-placeholder', '#message-modal').html(data.message)
45                $('#message-modal').modal()
46
47
48                // simple alert
49                //alert(data.message);
50
51
52                $('input[type=text], input[type=email], input[type=tel], input[type=file], select, textarea', form).val('')
53
54                if (formName == 'ask') {
55                    ym(85004512,'reachGoal','form_success_ask-question')
56                }
57                if (formName == 'call') {
58					ym(85004512,'reachGoal','form_success_call-order')
59                }
60				if (formName == 'call2') {
61					ym(85004512,'reachGoal','call-promo')
62                }
63
64
65            } else {
66                for (var field in data) {
67                    var errorTag = $('<ul class="errors" />')
68                    for (var i in data[field]) {
69                        errorTag.append('<li>'+data[field][i]+'</li>')
70                    }
71                    $('[name='+field+']', form).after(errorTag)
72                }
73            }
74            $('input[type=submit]', form).val($('input[type=submit]', form).data('defaultValue')).prop('disabled', false)
75
76            $('#loading').hide()
77
78        }, error: function() {
79            alert('invalid response')
80        }
81    })
82    return false
83
84})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.