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

# up.radio.startPolling(fragment, [options])

Starts [polling](https://unpoly.com/api/up-poll.md) the given element.

The given element does not need an [`[up-poll]`](https://unpoly.com/api/up-poll.md) attribute.

---

## Parameters {#parameters}

### General {#parameters-general}

#### fragment {#fragment}

(required)

The fragment to reload periodically.

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

#### [options] {#options}

(optional)

Options for reloading the fragment.

By default Unpoly will parse options from the fragment's attributes (see [`[up-poll]`](https://unpoly.com/api/up-poll.md)). You may pass this additional `options` object to [supplement or override](https://unpoly.com/learn/attributes-and-options.md#options) options parsed from the fragment's attributes.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

### Trigger {#parameters-trigger}

#### [options.interval] {#options.interval}

(optional)

The reload interval in milliseconds.

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

Type: number

#### [options.ifLayer='front'] {#options.ifLayer}

(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.

Type: string

### Request {#parameters-request}

#### [options.url] {#options.url}

(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).

Type: string

#### [options.method='get'] (Experimental) {#options.method}

(optional)

The HTTP method used to reload the fragment.

Type: string

#### [options.headers={}] {#options.headers}

(optional)

A JSON object with additional request headers.

Type: string

#### [options.params={}] {#options.params}

(optional)

A JSON 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.

Type: string

### Client state {#parameters-client-state}

#### [options.keepData=false] (Experimental) {#options.keepData}

(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.

Type: boolean

### Loading state {#parameters-loading-state}

#### [options.disable] {#options.disable}

(optional)

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

Type: boolean | string | [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)

#### [options.placeholder] (Experimental) {#options.placeholder}

(optional)

A [placeholder](https://unpoly.com/learn/placeholders.md) to show within 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.

Type: string | [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) | [List](https://unpoly.com/api/List.md)<[Node](https://developer.mozilla.org/en-US/docs/Web/API/Node)>

#### [options.preview] {#options.preview}

(optional)

One or more [previews](https://unpoly.com/learn/previews.md) that temporarily change the page while new content is loading.

The preview changes will be reverted automatically when the request ends for any reason.

Type: string | Function([up.Preview](https://unpoly.com/api/up.Preview.md)) | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)

#### [options.feedback=true] {#options.feedback}

(optional)

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

Type: boolean

