Difference between GET/POST/PUT/DELETE in Ajax in MVC pattern
I understand that GET is typically associated with a URL where you can put in the browser and get the exact action done again, like viewing a profile for a开发者_JS百科 particular person.
I am implementing MVC pattern with CI, and with a $.ajax of type:GET to the following URL:
url : 'index.php/con/fx1',
where con is the controller, fx 1 is a function in the controller.
I can direct fx1 to any model and do anything, be it POST, DELETE, or just READ.
In this sense, what difference does it make whether I specify GET/POST/DELETE/PUT
I'm a ruby on rails developer. But the MVC pattern is common for all (including php framework). I'm described in my way.
GET /con #=> index
GET /con/1 #=> show
GET /con/new #=> new
GET /con/1/edit #=> edit
PUT /con/1 #=> update
POST /con #=> create
DELETE /con/1 #=> destroy
for more: http://en.wikipedia.org/wiki/Representational_State_Transfer
The difference is in describing intent. I could, of course, submit a form using either GET or POST. The difference is that in REST a GET means one thing, a POST means another.
Even when there aren't technical reason for differentiating request types, there may be conceptual reasons for doing so.
GET
and POST
serve very different purposes. As do PUT
and DELETE
. Rather than repeat what many, many others have already said on this topic, Google difference between GET and POST
.
精彩评论