When I have to get something from my server and pass some value to it I'm currently using $.post('myserver/formhandler.php', { 'v' : value })
, and in my formhandler.php file I have the following:
require_once("mainclass.php");
require_once("config.php");
if(isset($_POST['v'])) {
$mainclass->FunctionA($_POST['v']);
}
if(isset($_POST['s'])) {
$mainclass->FunctionB($_POST['s']);
}
and so on. The thing is that sometimes I want to load something without passing any value, and my doubt is if it's faster do use the same $.post() function and pass a variable just to be able to trigger some function in the same file or if it would be better to use $.load() and have one specific file for each function, like $.load('LoadFunctionC.php')
, where LoadFunctionC.php would be something like:
require_once("mainclass.php");
require_once("config.php");
$mainclass->FunctionC();
Would it slow down my website for, for example, calling mainclass.php and config.php multiples times? Thanks!