首页 \ 问答 \ 如何通过Ajax API处理多个请求?(How to handle multiple requests through an Ajax API? [closed])

如何通过Ajax API处理多个请求?(How to handle multiple requests through an Ajax API? [closed])

我有一个大项目需要通过Ajax调用处理多个函数,到目前为止我使用不同的文件来处理每个函数调用。 我知道必须有更好的方法来通过API处理请求

那么在结构方面设计这样一个API的标准做法是什么?

谢谢!


I have a large project that requires multiple functions to be processed through Ajax calls, so far I am using different files to handle each function call. I know there's got to be a better way to handle the requests through an API

And what would be a standard practice for designing such an API in terms of structure?

Thanks!


原文:https://stackoverflow.com/questions/28758882
更新时间:2024-04-24 19:04

最满意答案

如您所知,默认模块中的控制器名称不需要前缀(Ex: SomeController ),而非默认模块中的控制器需要前缀(例如: Admin_SomeController )。

在基于模块的应用程序中,我个人发现使用模块名称为所有控制器添加前缀更加一致。 这是作为一个问题提交的,并通过添加前端控制器设置prefixDefaultModule 显然在版本1.5中 prefixDefaultModule

因此,在application/configs/application.ini ,您可以添加:

resources.frontController.prefixDefaultModule = true

我一直都在使用它,并认为它很棒。 ;-)


As you note, controller names in the default module do not require prefixing (Ex: SomeController), while controllers in non-default modules require prefixing (Ex: Admin_SomeController).

In module-based app, I personally find it more consistent to prefix all controllers with the module name. This was filed as an issue and fixed in apparently in version 1.5 by adding a front controller setting prefixDefaultModule.

So, in application/configs/application.ini, you could add:

resources.frontController.prefixDefaultModule = true

I use it all the time and think it's great. ;-)

相关问答

更多