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:
- function generatePerson() {
- $.ajax({
- url: "php/full_name.php",
- method: "POST",
- data: {post_ismale: true},
- dataType: "html",
- success: function() {
- $("#data").load("php/person.php");
- }
- });
- }
Now, the code works fine EXCEPT for the data that is being sent (post_ismale). This code returns nothing on the PHP side:
- 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.