David Ly
David Ly

Reputation: 31596

Can you make a cross subdomain form POST (non-javascript)?

I found lots of answers regarding AJAX calls, but I had trouble finding an answer for just a straight up HTML form without using Javascript.

Can you post a form from foo.mydomain.com/somepage to bar.mydomain.com/someotherpage?

Upvotes: 2

Views: 4720

Answers (2)

Quentin
Quentin

Reputation: 944084

Just use an include the hostname in the action attribute.

<form action="//bar.example.com/someotherpage" method="post">

Upvotes: 1

Pekka
Pekka

Reputation: 449693

I found lots of answers regarding AJAX calls, but I had trouble finding an answer for just a straight up HTML form without using Javascript.

Sure. You can post forms wherever you want, including other domains, ports, and even protocols.

The only thing you can't do is submit a form pointing to a different domain, port or protocol into an iframe, and then try to access its contents using JavaScript. That gets blocked by the Same Origin Policy (this can be overcome for subdomains though I think). Other than that, forms have no restrictions.

Upvotes: 6

Related Questions