【发布时间】:2016-02-13 04:18:17
【问题描述】:
当我必须从我的服务器获取一些东西并将一些值传递给它时,我目前正在使用$.post('myserver/formhandler.php', { 'v' : value }),并且在我的 formhandler.php 文件中我有以下内容:
require_once("mainclass.php");
require_once("config.php");
if(isset($_POST['v'])) {
$mainclass->FunctionA($_POST['v']);
}
if(isset($_POST['s'])) {
$mainclass->FunctionB($_POST['s']);
}
等等。问题是有时我想在不传递任何值的情况下加载一些东西,我怀疑它是否更快使用相同的 $.post() 函数并传递一个变量只是为了能够触发同一个文件中的某个函数,或者如果最好使用 $.load() 并为每个函数创建一个特定文件,例如 $.load('LoadFunctionC.php'),其中 LoadFunctionC.php 类似于:
require_once("mainclass.php");
require_once("config.php");
$mainclass->FunctionC();
它会减慢我的网站,例如多次调用 mainclass.php 和 config.php 吗? 谢谢!
【问题讨论】:
-
请查看ericlippert.com/2012/12/17/performance-rant,看看您是否可以让您的帖子在 SO 上更加具体/可回答。
标签: php jquery ajax performance