Html Amp Post shows the current page url?

490 views Asked by At

The Html Amp Post goes to the current url?.

<!doctype html>
<html ⚡>
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-form" rc="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
</head>
<body>
    <form class="-amp-form" method="post" target="_top" novalidate="" action-xhr="/Home/About">
        <input name="name" class="data-input" required="" type="text" placeholder="Name...">
        <input name="email" class="data-input" required="" type="email" placeholder="Email...">
        <input class="button button-primary" type="submit" value="Subscribe">
    </form>
</body>
</html>

Hovering over the submit input button in a browser shows the current url and clicking the button appears to do nothing (using httpFiddler there is no post or get request occuring). The solution is a standard MVC 5 application with the layout changed to include the amp ⚡ symbol in Html declaration and scripts included. Any ideas why it would show the current url when hovering over the button for example https://localhost:44331/Home/Index and not make any posts with the above code when the form button is clicked?

here is one of the resources i have been following from: https://ampbyexample.com/components/amp-form/

1

There are 1 answers

1
HonourCode On

The post was working, it just wasn't redirecting to the view after posting. The browser uses the 'action' property on the form to show the url that the user will be sent to and as this value is omitted for an amp action-xhr post it was just showing the current url; however it was still posting to the correct url when clicked. What i was looking to do is a post and redirect and it seems that currently only Get amp requests support page redirection. This might change in the future but for now it needs to use Get requests for page redirecting.