Doubts $ http AngularJs

0

I have a form where some inputs that will be used to make a filter, just as there are many, not to pass the fields via GET like this: Ex:? Filter1 = test & filter2 = test2 ..., can I use the $ http.post method of angularjs without any problem? Is it wrong to use it that way?

    
asked by anonymous 16.11.2015 / 11:50

2 answers

2

There is no problem in using the POST method, rather than GET. This method is safer and has better data capacity than GET. In this method a parallel connection is opened and data is passed by it. There is no size restriction (however this size can be limited if you wish, just make this small configuration on the server: php_value post_max_size 20M ), in addition the data is not visible to the user.

The GET method is recommended when you want to pass small / small information to perform a search or simply pass information to another page through the URL (address bar).

What can not happen is that your requests result in changes in the content of the response. The function of the GET method is simply to retrieve an existing resource on the server, if you use it to change data, you are misusing it and opening up security holes.

The result of a GET request is "cacheable" by the client, ie it is in the browser's history.

Please read this at

16.11.2015 / 12:30
0

Guilherme, as quoted by @MuriloMittmann, it is possible to do yes, but it was not done for that, the ideal is to use GET .

The http protocol describes that GET must be used to request resources, so this request does not change the state of the server, so multiple requests in a sequence can occur without generating problems.

Regarding POST , the protocol describes that it is for submitting forms or sending information for processing that will possibly lead to a change in the state of the server.

So, philosophically correct would be to use GET .

    
16.11.2015 / 12:16