metafizzy / infinite-scroll

📜 Automatically add next page
https://infinite-scroll.com
7.41k stars 1.74k forks source link

how could i get the ajax responce in the error.infinityScroll fn ? #922

Closed jayenne closed 3 years ago

jayenne commented 4 years ago

Hi, I am using infiniteScroll to call my api which returns data along with a status code (404) to trigger the error.infiniteScroll to show some html response return by my api.

My problem is that I just can't find a way get the response data in this function. is there any way to do this*?

either inside the plugin or a workaround of sorts.

I'm using Laravel via API the returns json + status code and the following infiniteScroll settings:

$grid.infiniteScroll({
          path: function() {
            return url+'?page=' + (this.loadCount +1); 
          },
          checkLastPage: false,
          append: griditem,
          outlayer: $pkry,
          prefill: true,
          history:false,
          status: '.page-load-status'
        });

all works well with the exeption of accessing the response. thanks.

jayenne commented 4 years ago

Hi, in he case of an error response being triggered (error.infiniteScroll), Is is possible to get the server's returned response status_code as well as the returned error message (instead of the default code message)?

I may well be tackling my issue wrongly. I'd like to perfom a followup call based on the error. For instance, when i get a 404 response, I'd like to go back to the server to return some other data (an error specific image or html ).