Section Rendering API
You can use the Section Rendering API to request the HTML markup for theme sections using an AJAX request. This can allow you to update page content without reloading the entire page by fetching and dynamically replacing only certain elements.
For example, you can use the Section Rendering API to paginate search results without performing a full page reload between pages.
Request sections
Anchor link to section titled "Request sections"You can use the sections
query parameter to render up to five sections, identified by their section IDs. The response is a JSON object that includes pairs for each section ID and its corresponding rendered HTML.
The sections
parameter can be a comma-separated list of IDs or an array:
Sections can be rendered in the context of any page by appending the sections
parameter to any page URL. For example, you can request /?sections=sections--1234__header
for the root page, or you can request /collections/featured?sections=sections--1234__header
for a featured collection page.
The following example code requests two sections using a JavaScript XMLHttpRequest
: