PHP / AJAX从Ajax获取ID

First of all sorry for the English:) so hello im a new web programmer and im working on some school manager project.

i have to display all courses in school and then when i click course display his description.

this is my display php code

    <?php
$conn = mysqli_connect("localhost", "root", "", "school");

        if($conn){      
        $result = $conn->query("SELECT * FROM `courses`");
        if ($result->num_rows > 0){
            while($row = $result->fetch_assoc()){
                $id=$row['id'];
                echo '<div class="alex" onclick="myFunction(this.id)" id="'.$id.'">'.$row['name'].'</div>'.'<br>'.'<br>';
            }
        } 
        }else{
            echo die("connection faild"); 
        }  

        mysqli_close($conn);        
?>

as you can see i gave it the id of the table which i what to display description.

that is my function code in js file

     function myFunction(id){
        $.post(
            "api/courses/description.php",
            {  id:id }
        ).done(function( data ) {
            console.log(id);
            $('#desc').load("api/courses/description.php");
        });
    }

and here is my description php to get id and display description:

<?php $conn = mysqli_connect("localhost", "root", "", "school");
if (isset($_POST['id'])) {
$id = $_POST['id'];
}
if($conn){ $result = $conn->query("SELECT * FROM courses WHERE id = '$id'");
    if ($result->num_rows > 0){
        while($row = $result->fetch_assoc()){
            echo $row['description'];
        }
    } 
    }else{
        echo die("connection faild"); 
    }     
    mysqli_close($conn); ?>

when i click the displayed courses i get the ids on console! For every course I click I get his id on console.

hope you could help me! Im sittin on it for many hours and cant get the problem.

hope its readable T_T

edit:forgot to say.. error i have is

Notice: Undefined index: id in C:\xampp\htdocs\project\api\courses\description.php on line 9---cant get id NULL ----------------------------------------> on var dump

Notice: Undefined variable: id in C:\xampp\htdocs\project\api\courses\description.php on line 10 (---->id = $id undefined -> $id)

You're calling description.php twice. First you call it in an AJAX POST request and successfully supply it the id parameter. This does not generate an error. But then look at what you do with the result of that operation:

console.log(id);
$('#desc').load("api/courses/description.php");

You log the id, which is also successful. Then you ignore the data response and call description.php again. This time as an AJAX GET request where you do not supply it with the id parameter. This is what generates the errors.

Instead of making the second request, just use the returned value of the first request. It looks like you want something like this:

console.log(id);
$('#desc').html(data);