Z
Z
zepy2018-06-01 10:31:52
AJAX
zepy, 2018-06-01 10:31:52

404 error occurs when resubmitting ajax request, how to fix?

On the first submission, everything works fine, but on the next one, a 404 error occurs.

$(document).ready(function()  {
    $( ".like-info__left a" ).click(function( e ) {
        e.preventDefault();
        var button = $(this),
            parent = button.parents('.rating-info'),
            url = button.attr('href'),
            data = button.find('.rating-info__btn-number');
        console.log(button.attr('href'));
        $. ajaxSetup ({cache: false});
        $.ajax({
            type: 'post',
            url: url,
            data: {class: parent.data('class'), id: parent.data('id')},
            success: function (result) {
                button.addClass('active');
                data.text(+data.text() + 1);
                console.log(result);
            }
        });
    });
});

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