Search code examples
javascriptpolymer

How to use an iron-ajax response on another page, in Polymer?


How do I pass the response of an iron-ajax to another page?

I have two pages which will display different things from the same data(response). Is there a way to pass the response of an iron-ajax in page-x.html to page-y.html without generating the same request in each page.


Solution

  • here the very simple code to pass the iron-ajax 's response to two or more page (element- components); And if you have a specific requirement then re-issue your question in order to make more specific answer.:

    <iron-ajax 
             auto
             id="request"
             url="your url here "
             last-response="{{response}}"
    > </iron-ajax>
    <page-x x-data = "{{response}}"></page-x>
    <page-y y-data = "{{response}}"></page-y>
    

    at page-x you will have a xData and at page-y you will have yData property with received data from iron-ajax