开发者

Difference between GET/POST/PUT/DELETE in Ajax in MVC pattern

开发者 https://www.devze.com 2023-04-05 17:05 出处:网络
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 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.

0

精彩评论

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