metafizzy / metafizzy/infinite-scroll
checkLastPage not working when retrieving JSON
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 7.5k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I'm using Infinite Scroll with this code :
``` js
$container.infiniteScroll({
path: function() {
var pageIndex = this.pageIndex + 1;
var url = jQuery('#posts').data('url');
url = url+pageIndex;
return url;
},
append: false,
responseType: 'text',
});
$container.on( 'load.infiniteScroll', function( event, response ) {
var data = JSON.parse( response );
$container.append( data.content );
});
```
But, when "/getLastPost" url is returning a blank JSON, infinite scroll is not detecting that empty result and is still trying to load the next page.
How can I fix this ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown infiniteScroll configuration, especially the path callback and the load.infiniteScroll handler, and reproduce the behavior against an endpoint that returns blank JSON for /getLastPost. Check how checkLastPage handles responseType: 'text' and the parsed response; done means an empty final response does not trigger another page request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100