MVC模式中Ajax中GET/POST/PUT/DELETE的区别

发布于 2024-12-05 02:20:48 字数 331 浏览 2 评论 0原文

据我所知,GET 通常与 URL 相关联,您可以将其放入浏览器中并再次完成确切的操作,例如查看特定人员的个人资料。

我正在使用 CI 实现 MVC 模式,并使用类型为:GET 的 $.ajax 到以下 URL:

                url         : 'index.php/con/fx1',

其中 con 是控制器, fx 1 是控制器中的一个函数。

我可以将 fx1 定向到任何模型并执行任何操作,无论是发布、删除还是只是读取。

从这个意义上说,我是否指定 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走走停停 2024-12-12 02:20:49

我是一名 Ruby on Rails 开发人员。但MVC模式对于所有人来说都是通用的(包括php框架)。我以我的方式描述。

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  

了解更多:http://en.wikipedia.org/wiki/Representational_State_Transfer

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

我不吻晚风 2024-12-12 02:20:49

区别在于描述意图。当然,我可以使用 GET 或 POST 提交表单。不同之处在于,在 REST 中,GET 意味着一件事,POST 意味着另一件事。

即使没有区分请求类型的技术原因,也可能存在概念原因。

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.

绳情 2024-12-12 02:20:49

GETPOST 的用途截然不同。 PUTDELETE 也是如此。与其重复很多很多其他人已经就这个主题说过的话,谷歌GET和POST之间的区别

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文