开发者

Should I use a mixture of POST and GET for this form sequence?

I have a sequence of forms that follows the following algorithm:

Form #1

  1. Prompt for input of value A.
  2. Send X* request with value A.

Form #2

  1. Display value A and prompt for input of value B.
  2. Send POST request with value A and开发者_开发百科 B.

*Should X in step 2 be GET or POST? I was just going to make it POST, but hesitated and wondered if I should use GET since form #1 is just passing a value(s) to form #2 and not POSTing it to a database.

Thanks!


Make a POST, since its objective is to provoke a side-effect server-side (in particular, to change the state of the multi-page form).

RFC 2616 says in section 9.1.1:

In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.

Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜