-1

I came across a situation where someone wanted me to implement Sorting, Search, record-per-page and pagination through POST request rather than GET. I tried him to tell why POST is not feasible, Like

  1. User will not be able to bookmark the page
  2. Through POST we cannot maintain paging params when search returns records greater than record per page.
  3. Sorted order will not be maintained when user navigates to next page by clicking page number.

Then he suggested me to keep search, sorting and paging values in cookies for that instance, once user moves to other page we can clear the cookies, or we keep in session

Please help me to decide is this right way of doing the things?

Ashu Jha
  • 344
  • 2
  • 9
  • You can do it via post too, why don't you use cookies? It must be more easier. Anyways your question too board – Muhammad Hassaan Jul 19 '16 at 07:36
  • Do you tried just to add `mtype: "POST"` option to jqGrid? It will send to the server HTTP POST instead HTTP GET used by default. – Oleg Jul 19 '16 at 10:49
  • @Oleg Please get through the Question once again. – Ashu Jha Jul 20 '16 at 09:54
  • @AshuJha: I think that you misunderstand the problem. jqGrid uses HTTP POST or HTTP GET **for internal Ajax requests** only. **The options** of jqGrid (search, sorting and paging values) are independent from the main HTML page, which contains jqGrid. You can save any options of jqGrid in `localStorage` or in cookie and still use HTTP POST for Ajax requests which jqGrid makes. Try [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/ColumnChooserAndLocalStorage2_singleSelect.htm), created for [the answer](http://stackoverflow.com/a/31663268/315935). Change sorting and so on and reload the page. – Oleg Jul 20 '16 at 10:53

2 Answers2

0

So, I don't want to jump into the middle of your company dispute, but I understand the situation your in and realize that sometimes you need someone on your side.

1). First, POST os NOT for getting, so by definition, he is wrong. If you are not creating anything, you simply do not POST. See here.

2). Your point about not being able to bookmark the page for access later is comletely valid.

3). No. No, no, no. Do not store that stuff in the session or cookies. While it won't harm anything, it's completly unnecessary. It isn't sensitive data, and technically speaking it could work. However, you would only need to do this if you had already broken the first point and used some verb other than GET.

If you are paginating, sorting, etc it is because you have receieved data. You cannot receive information unless you first GET it, right?

Zac Brown
  • 459
  • 4
  • 12
0

First of all you should make him understand where to use GET, and Where to use POST.

I am giving here in short, for detailed information you can ask to google.

GET: Usually used to submitted the search request or any request where user wants to pull the information from the server.

Advantage of GET . 1. page can be bookmarked. 2. page can be reloaded safely.

POST: Used for request where data may be altered or added in database. or page what you don't want someone bookmark.

Advantage of POST.

  1. Name value pair is not shown in URL. So this is plus point for security.
  2. Unlimited number name value pair is passed.

Basically as I mentioned POST is used for destructive action such as creation, editing or deletion. And for pulling the data we mainly use GET.

and what is the need to put the search param in to cookies, Because as far as I think you are doing all the stuff like sorting or searching on server side, So You will have to pass that in to url every time (or POST body If you follow the path suggested by your Einstein Senior :) ), So no need to fill the cookies space

I hope this will help and he will understand.

localhost
  • 483
  • 4
  • 10