I'm using a lot of AJAX calls where I'll say,
data: {action: "get_categories", etc..}
and then in my PHP I'll say,
if(isset($_POST['action']) && ($_POST['action'] == 'get_categories')) {
//do stuff
}
I'm trying to refactor the code a bit, and I'd like to take the output of one of these code blocks and pass it into another one, but its not a PHP function, so I'm not really sure how to do that? Is there a way to call a PHP function directly from the AJAX call, rather than using action?
Also, in using this style of PHP code block I have to call the code below in every single code block, and I'm not sure why? I thought if I put it at the top of my php file, and used require_once that might work but nothing I try works unless I include these in every single code block.
require("config.php");
require("database.php");