Search code examples
jsonamp-html

How to load JSON into AMP page?


I have a AMP page and i need to make it dynamic. How to load Json in AMP page? My json code inside the AMP page shows 'Not a valid AMP page' Error.

Please Help.


Solution

  • You can't do it - AMP is static HTML ( you can add dynamic only from server-side which generate the page )

    Either you can check amp-state. See https://www.ampproject.org/docs/tutorials/interactivity/remote-data for more details

      <amp-state id="selected">
        <script type="application/json">
          {
            "slide": 0,
            "sku": "1001"
          }
        </script>
      </amp-state>