ajax.php 802 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. if (is_ajax()) {
  3. if (isset($_POST["venue"]) && !empty($_POST["venue"])) { //Checks if action value exists
  4. // $action = $_POST["action"];
  5. // switch ($action) { //Switch case for value of action
  6. // case "test":
  7. test_function();
  8. // break;
  9. //}
  10. }
  11. }
  12. //Function to check if the request is an AJAX request
  13. function is_ajax()
  14. {
  15. return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
  16. }
  17. function test_function()
  18. {
  19. $return = $_POST;
  20. //Do what you need to do with the info. The following are some examples.
  21. //if ($return["favorite_beverage"] == ""){
  22. // $return["favorite_beverage"] = "Coke";
  23. //}
  24. //$return["favorite_restaurant"] = "McDonald's";
  25. $return["json"] = json_encode($return);
  26. echo json_encode($return);
  27. }