最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Difference between GETPOSTPUTDELETE in Ajax in MVC pattern - Stack Overflow

programmeradmin1浏览0评论

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 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 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 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

Share Improve this question asked Sep 17, 2011 at 1:24 William ShamWilliam Sham 13.2k11 gold badges51 silver badges67 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

I'm a ruby on rails developer. But the MVC pattern is mon 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/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)

  1. 暂无评论