Should links ever have side effects in terms of condition?

I made life difficult for HTML / CSS developers by making any interaction that has a side effect and NOT a hyperlink.

For example, I changed the "Empty Cart" on the shopping site using the link to the button. Based on the assumption that any action that has a side effect should be a button, not a hyperlink. (even a spider or robot will never get to this point) How does this relate to REST?

The best answer would be for good reason why I can use why I'm making it difficult for the HTML / CSS guys ... or why I'm wrong :-), ... maybe I'm purist, but for some reason?

Note. I would not mind adding ajax functionality that has certain side effects on a hyperlink or even on an event changed by selection.

Greetings. Murray

+3
source share
3 answers

I think you did the right thing, but the excuse is probably outside the "REST" domain.

If these links are really tags <a>that cause the browser to make a GET request and then click, then they should not have any side effects, because it is assumed that the GET conforms to the HTTP specification, which is safe and idempotent. See previous comments about link spiders, etc.

, "" javascript, POST - , A-OK HTTP. , , , RESTful.

. HTML CSS javascript GET, 1994 , , . - , . , .

+4

REST, :

Hyperlinks are for navigation.
Buttons are for interaction.
+2

It doesn't really matter if your β€œstates” are valid links or buttons. You may have a link that removes / adds, etc. Consistency is important. Therefore, if you want these actions to be buttons, this is normal. I think talented CSS users can make links look like buttons. You may not need html buttons.

+1
source

Source: https://habr.com/ru/post/1717309/


All Articles