GithubHelp home page GithubHelp logo

Comments (5)

fieg avatar fieg commented on June 9, 2024

Hi @altendorfme, you have to call this.append, from the nextHandler (from the final then call).

return this.append(Array.from(frag.childNodes))
        // indicate that there is a next page to load
        .then(() => hasNextPage);
    });

See this code for how to do this:
https://codesandbox.io/s/github/webcreate/infinite-ajax-scroll/tree/master/examples/json?file=/index.js

Please let me know if this helps.

from infinite-ajax-scroll.

altendorfme avatar altendorfme commented on June 9, 2024

Hi @fieg ,

There are two Ajax calls, the first is to bring the next URL:

[
  {
    "nextId": 2109671,
    "nextUri": "https://next.com/next-post/"
  }
]

The second call ias would take the information from the URL (nextUri), bringing the content.

I fork code, maybe it's easier in: https://codesandbox.io/s/romantic-cdn-yqurq

from infinite-ajax-scroll.

fieg avatar fieg commented on June 9, 2024

This is not a common use pattern for IAS. Why does the next url need to come from a json call? If you could tell me a bit more about your use case I can help you better.

from infinite-ajax-scroll.

altendorfme avatar altendorfme commented on June 9, 2024

Hi, this API route (With ElasticSearch) returns smarter related results.

from infinite-ajax-scroll.

fieg avatar fieg commented on June 9, 2024

I think this should do the trick:

function nextHandler(pageIndex) {
  return fetch("./static/post.json")
    .then((response) => {
      return response.json();
    })
    .then((data) => {
      let hasNextPage = pageIndex + 1 < data.length;
      let nextUrl = data[pageIndex].nextUri;

      return this.load(nextUrl).then((data) => {
        return this.append(data.items).then(() => {
          return hasNextPage;
        });
      });
    });
}

https://codesandbox.io/s/relaxed-feynman-ofl38?file=/index.js

from infinite-ajax-scroll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.