---
name: "[up-poll]"
area: "API"
kind: "HTML attribute"
parent: "up.radio module"
url: "https://unpoly.com/api/up-poll"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.radio module](https://unpoly.com/api/up.radio.md)</nav>

# [up-poll]

Elements with an `[up-poll]` attribute are [reloaded](https://unpoly.com/api/up.reload.md) from the server periodically.

<nav aria-label="Guides">

- [Learn: Polling](https://unpoly.com/learn/polling.md)

</nav>

## Example {#example}

This fragment `#score` will be reloaded every 30 seconds:

```html
<div id="score" up-poll>
  Score: 1400
</div>
```

---

## Modifying attributes {#attributes}

### Trigger {#attributes-trigger}

#### [up-interval] {#up-interval}

(optional)

The reload interval in milliseconds.

Defaults to [`up.radio.config.pollInterval`](https://unpoly.com/api/up.radio.config.md#config.pollInterval), which defaults to 30 seconds.

#### [up-if-layer='front'] (Experimental) {#up-if-layer}

(optional)

Controls polling while the fragment's [layer](https://unpoly.com/api/up.layer.md) is covered by an overlay.

When set to `'front'`, polling will pause while the fragment's layer is covered by an overlay. When the fragment's layer is uncovered, polling will resume.

When set to `'any'`, polling will continue on background layers.

### Request {#attributes-request}

#### [up-href] {#up-href}

(optional)

The URL from which to reload the fragment.

Defaults to the URL this fragment was [originally loaded from](https://unpoly.com/api/up-source.md).

#### [up-method='get'] (Experimental) {#up-method}

(optional)

The HTTP method used to reload the fragment.

#### [up-headers] {#up-headers}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object with additional request headers.

#### [up-params] {#up-params}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object with additional [parameters](https://unpoly.com/api/up.Params.md) that should be sent as the request's [query string](https://en.wikipedia.org/wiki/Query_string) or payload.

When making a `GET` request to a URL with a query string, the given `{ params }` will be added to the query parameters.

#### [up-fail] {#up-fail}

(optional)

How to handle [error responses](https://unpoly.com/learn/error-responses.md).

By default, polling will skip server responses with an error code, even when the response contains a matching fragment. After the configured interval, the server will be polled again.

Set `[up-fail=false]` to render _any_ response that contains a matching fragment, even with a 4xx or 5xx status code.

### Client state {#attributes-client-state}

#### [up-keep-data] (Experimental) {#up-keep-data}

(optional)

Whether to [preserve](https://unpoly.com/learn/data.md#preserving) the polling fragment's [data object](https://unpoly.com/learn/data.md) through reloads.

### Loading state {#attributes-loading-state}

#### [up-disable] {#up-disable}

(optional)

[Disables form controls](https://unpoly.com/learn/disabling-forms.md#from-link) while the link is loading.

#### [up-placeholder] (Experimental) {#up-placeholder}

(optional)

A [placeholder](https://unpoly.com/learn/placeholders.md) to show in the targeted fragment while new content is loading.

Existing children of the targeted fragment [will be hidden](https://unpoly.com/learn/placeholders.md#basic-example) during the request. When the request ends for any reason, all changes will be reverted.

You can either [pass a HTML string](https://unpoly.com/learn/placeholders.md#basic-example) or [refer to a template](https://unpoly.com/learn/placeholders.md#from-template), optionally with [variables](https://unpoly.com/learn/placeholders.md#dynamic-templates).

If this link [opens a new overlay](https://unpoly.com/learn/opening-overlays.md), the placeholder will be shown in a temporary overlay with the same [visual style](https://unpoly.com/learn/customizing-overlays.md) and open animation.

#### [up-preview] {#up-preview}

(optional)

The name of a [preview](https://unpoly.com/learn/previews.md) that temporarily changes the page while new content is loading.

The preview changes will be reverted automatically when the request ends for [any reason](https://unpoly.com/learn/previews.md#ending).

#### [up-feedback='true'] {#up-feedback}

(optional)

Whether to set [feedback classes](https://unpoly.com/learn/feedback-classes.md) while loading content.

