2

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.

2 Answers 2

4

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>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. Is there any video tutorial available for AMP development?
@HelloWorld text-tutorial is pretty good ampproject.org/docs/tutorials/create
1

You can also use amp-list

The amp-list component fetches dynamic content from a CORS JSON endpoint. The response from the endpoint contains data, which is rendered in the specified template.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.