Skip to content

photoshelter/iron-ajax

 
 

Repository files navigation

Build status

Demo and API docs

Changes in 2.0

  • Promise polyfill is now a dev dependency and no longer shipped with iron-ajax
  • New features introduced in #265

TODO: remove flag in #265 when we can introduce breaking changes

<iron-ajax>

The iron-ajax element exposes network request functionality.

<iron-ajax
    auto
    url="https://www.googleapis.com/youtube/v3/search"
    params='{"part":"snippet", "q":"polymer", "key": "YOUTUBE_API_KEY", "type": "video"}'
    handle-as="json"
    on-response="handleResponse"
    debounce-duration="300"></iron-ajax>

With auto set to true, the element performs a request whenever its url, params or body properties are changed. Automatically generated requests will be debounced in the case that multiple attributes are changed sequentially.

Note: The params attribute must be double quoted JSON.

You can trigger a request explicitly by calling generateRequest on the element.

<iron-request>

iron-request can be used to perform XMLHttpRequests.

<iron-request id="xhr"></iron-request>
...
this.$.xhr.send({url: url, body: params});

Packages

 
 
 

Languages

  • HTML 100.0%