简体   繁体   English

什么PHP策略可以用来支持前端ajax调用?

[英]what php strategy to use to support frontend ajax calls?

I want to refactor my php site which supports a front end which makes ajax calls. 我想重构支持前端进行ajax调用的php网站。 Currently my ajax calls a php page which stores all my backend code and based on the parameters passed from the ajaxcall it determines which php methods to run. 目前,我的ajax调用了一个php页面,该页面存储了我所有的后端代码,并根据从ajaxcall传递的参数来确定要运行的php方法。

I realize building a rest API as the php backend woudl be better but was wondering if there is another alternative? 我意识到构建一个REST API会更好,因为php后端woudl更好,但是我想知道是否还有另一种选择? ie a good way to structure a php page that allows for clean re-usable ajax calls from the front end? 即一种构造php页面的好方法,该页面允许从前端进行干净的可重用ajax调用?

Thanks 谢谢

There are multiple ways of doing such kind of web development. 进行这种Web开发有多种方法。 It could be REST based micro framework approach in PHP where you invoke different views. 它可能是PHP中基于REST的微框架方法,您可以在其中调用不同的视图。 Another could be to invoke the PHP code solely based on the input or interactions on the view (HTML/Javascript) using AJAX. 另一种可能是仅基于输入或使用AJAX在视图(HTML / Javascript)上的交互来调用PHP代码。 Depends what you want to achieve. 取决于您要实现的目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM