I have a simple question, I am currently handling php / ajax requests in the current way.
// ajax_requests.php
<?php
if(isset($_POST['ajaxvar'] == 'send')){
// send timestamp
}
if(isset($_POST['ajaxvar'] == 'get')){
// return get
}
?>
Is there a better way of coping with these requests? Other than this somewhat bloated way of handling with requests.
If you name your functions after the values you post in ‘ajaxvars’ then you can run them like this:
So if you have $_POST[‘ajaxvars’] == ‘send’, the script will run the send() function. Same for get.
It’s also a good idea to first check if the posted function exists, so: