jQuery AJAX not sending variable to PHP file

jQuery AJAX not sending variable to PHP file

Hello, I am just starting to use jQuery and am using AJAX. On the click of a button, this function is called on the JS side:

  1. function generatePerson() {
  2.     $.ajax({
  3.         url: "php/full_name.php",
  4.         method: "POST",
  5.         data: {post_ismale: true},
  6.         dataType: "html",
  7.         success: function() {
  8.             $("#data").load("php/person.php");
  9.         }
  10.     });
  11. }


Now, the code works fine EXCEPT for the data that is being sent (post_ismale). This code returns nothing on the PHP side:


  1. if (isset($_POST["post_ismale"])) {
            if ($_POST["post_ismale"] == "true") {
                $isMale = True;
            }
            else {
                $isMale = False;
            }
    }

I do not understand why sending the variable post_ismale is not working.