$ in $.ajax not defined in JavaScript

I’m using jQuery to connect HTML and Python, but the following code won’t work because $ is not defined. I researched it and found nothing that could help me that I haven’t already done.

<script
          src="https://code.jquery.com/jquery-3.6.4.min.js"
          integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
          crossorigin="anonymous"></script>
<script>
    
    function myFunction() {
    const firstname = document.getElementById('fname').value;
    const lastname = document.getElementById('lname').value;

    const dict_values = {firstname, lastname}
    const s = JSON.stringify(dict_values);
    console.log(s)
    window.alert(s)
    $.ajax({
        url:"/test",
        type:"POST",
        contentType: "application/json",
        data: JSON.stringify(s)});
}
  
</script>

I added more to the first script, but nothing changed.