Reputation: 28424
Any methods to submit a POST request from a link if JS is disabled?
Ideeas so far (none of them perfect)
I need a fallback method for browsers without JS, and my area for these "buttons" is too small for buttons or images
Upvotes: 14
Views: 12411
Reputation: 11432
You could make the button look like a normal link if you want using CSS?
Something like this perhaps?
<style type="text/css" media="screen">
input {
border: none;
background: none;
color: #00f;
text-decoration: underline;
cursor: pointer;
display: inline;
margin: 0;
padding: 0;
}
</style>
Click <input type="submit" value="here"/>!
Edit to add: The following CSS is just an example of how it might work, though not thorougly tested and to make it look like one of your normal links you might need to tweak it a bit.
Upvotes: 15
Reputation: 54011
The one solution I can think of is to have a form on the page with a button styled so that it simply looks like a text link.
When Javascript is enabled, you can gracefully hide this form and allow the normal link to take precident and if Javascript is disabled, allow the user to still use the system.
Upvotes: 2
Reputation: 944157
No, there isn't.
Links afford going somewhere. Buttons afford sending data somewhere.
If you want to use a link to make a POST request, then you are either sending confusing signals to users or you have your backend setup to use the wrong type of HTTP request for the task.
Upvotes: 2