Edit this page

up.network up.ajax([url], [options])
JavaScript function

This feature has been deprecated. Use up.request() instead.

Load unpoly-migrate.js to polyfill deprecated features.

Makes an AJAX request to the given URL and caches the response.

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

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

[url] string optional

The requested URL.

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

[options] Object optional

See options for up.request().

Return value

Promise<string>

A promise for the response text.