1

My app works fine, but I'm not sure if it's considered "bad practice" with what I'm doing for a particular knockout.js form.

I'm using CakePHP as the backend and knockout.js for a form on one of my views. On this view, the JavaScript file for the Knockout.js form containing the MVVM goodies is included. So, this knockout form accesses the JS script, and one of the functions involves this JS script sending a request out to a different PHP file. Right now this file is just in the root directory of my folder (not in the app directory), and since it's only interacting with the JavasScript directly and not CakePHP I'm wondering if this is a no-no. I guess you could think of it as this PHP file is interacting with the Knockout "system" and not the CakePHP "system".

I made this file a while back to do some calculations and it just seems easier to leave it this way considering I don't need a view or anything displayed from it. JSON format data is sent to it, and it sends modified data back to JavaScript in JSON format. Basically this php file only interacts with JavaScript and never with the CakePHP structure.

4

1 回答 1

1

如果它与 Cake 模型/控制器/...或任何东西没有任何关系。我认为它在 MVC 之外没有问题。它只能让它更快,而不必经过框架的路由和调度。

但是另一方面,如果它不对服务器上的数据做任何事情,那你为什么还需要服务器呢?你不能将逻辑移植到客户端吗?

于 2013-04-18T22:27:26.047 回答