AlexMorj2021-12-18 13:58:15
AlexMorj, 2021-12-18 13:58:15

Ajax on JS file not processing php file, ignore, who knows why?

The meaning is this. I have another site and there is exactly the same JS form for sending messages from the site to telegram, but for some reason this form does not process the php file on another site. Those. JS is processed as it should, up to the output of the final submission message, BUT ajax seems to ignore the PHP file, and therefore I can’t set up a feedback form. Who knows what could be the problem???

$('.wrapper-form').on('submit', function (event) {


    let form = this,
        submit = $('.submit', form),
        data = new FormData(),
        files = $('input[type=file]')

    $('.submit', form).val('Отправка...');
    $('input, textarea', form).attr('disabled','');

    data.append( 'Имя', 		$('[name="name"]', form).val() );
    data.append( 'Связь', 		$('[name="phone"]', form).val() );
    data.append( 'Сообщение', 	$('[name="mes"]', form).val() );

    files.each(function (key, file) {
        let cont = file.files;
        if ( cont ) {
            $.each( cont, function( key, value ) {
                data.append( key, value );
        url: '/php/telegram.php',
        type: 'POST',
        data: data,
        cache: false,
        dataType: 'json',
        processData: false,
        contentType: false,
        xhr: function() {
            let myXhr = $.ajaxSettings.xhr();

            if ( myXhr.upload ) {
                myXhr.upload.addEventListener( 'progress', function(e) {
                    if ( e.lengthComputable ) {
                        let percentage = ( e.loaded / e.total ) * 100;
                            percentage = percentage.toFixed(0);
                        $('.submit', form)
                            .html( percentage + '%' );
                }, false );

            return myXhr;
        error: function( jqXHR, textStatus ) {
            // Тут выводим ошибку
        complete: function() {
            success: swal({
                title: "Здравствуйте! Наш менеджер свяжется с Вами в ближайшее время.",
                type: "success",
                showConfirmButton: false,
                timer: 3000

    return false;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question