AlexanderKim's avatar

Ajax pagination not working

Tried to follow this tutorial: https://laraget.com/blog/how-to-create-an-ajax-pagination-using-laravel

But had no success. When i click on a pagination link, i get the following error:

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
0 likes
3 replies
Cronix's avatar

You should show your code. We have no idea what you've actually done.

AlexanderKim's avatar

Standart laravel pagination, here's jquery from the tutorial:

            $('body').on('click', '.pagination a', function(e) {
                e.preventDefault();

                var url = $(this).attr('href');
                getArticles(url);
                window.history.pushState("", "", url);
            });

            function getArticles(url) {
                $.ajax({
                    url : url
                }).done(function (data) {
                    $('#products').html(data);
                }).fail(function () {
                    alert('Articles could not be loaded.');
                });
            }

When i click on pagination item, normal page reload happens and shows that error

Cronix's avatar

I don't see your javascript wrapped in

$(function() {
 // rest of your js
}

That's the only code you show, so it's all I have to go on. I'm not going to assume you've copied/pasted all of the identical code from the tutuorial.

Please or to participate in this conversation.