Purpose
AJAX load/refresh content periodically, at a configurable interval.
Target | Purpose | Default |
---|
replace (Optional) | The element to replace when the fetch request succeed | the controller root element |
Value | Type | Description | Default |
---|
seconds | String | The number of seconds between each refresh. When the time has elapsed, the controller will send a Fetch request for the content. | - |
endpoint | String | The URL to fetch content from | - |
errorMessage (Optional) | String | The error message to display when the remote content fails to load | This content failed to load |
selector (Optional) | String | The CSS selector to use to extract the desired element(s) from the returned HTML response | Empty. The entire HTML response will be loaded |
maxRetries (Optional) | Number | How many times the controller should retry fetching the content in the event of network errors or bad responses | 1 |
Events
Event | When | Dispatched on | event.detail |
---|
poll-block:success | When the content is fetch successfully | the controller root element | - |
poll-block:error | When the block fails to get a response from the endpoint | the controller root element | - |
poll-block:complete | When the request finishes, regardless of success or failure | the controller root element | - |
Side Effects
None
How to Use
See Also
Async Block Controller
Lazy Block Controller
Load Block Controller