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

# up.ajax([url], [options])

**This feature has been deprecated**. Use [`up.request()`](https://unpoly.com/api/up.request.md) instead.

Load [`unpoly-migrate.js`](https://unpoly.com/changes/upgrading.md) to polyfill deprecated features.

Makes a request to the given URL and caches the response.

The function returns a promise that fulfills with the response text.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

```
up.ajax('/search', { params: { query: 'sunshine' } }).then(function(text) {
  console.log('The response text is %o', text)
}).catch(function() {
  console.error('The request failed')
})
```

---

## Parameters {#parameters}

### [url] {#url}

(optional)

The requested URL.

Instead of passing the URL as a string argument, you can also pass it as an `{ url }` option.

Type: string

### [options] {#options}

(optional)

See options for [`up.request()`](https://unpoly.com/api/up.request.md).

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

---

## Return value {#return-value}

A promise for the response text.

Type: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)<string>

