0

I have the problem even if I use the regular version of jquery

<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="https://code.jquery.com/jquery-3.5.1.min.js"><\/script>')</script>

html :

<button class="btn btn-secondary" type="button" id="save" onclick="save()">save</button>

ajax function :

function save(){
        $.ajax() ({
            type: 'POST',
            url: 'file.php',
            data: { name : name, content : content},
            dataType: 'json'
        });
}

Uncaught TypeError: $.ajax(...) is not a function

1 Answers1

2

You try to execute ajax() as a function, like so ajax() ({...}) this is why you get the error.

try:

function save(){
        $.ajax({
            type: 'POST',
            url: 'file.php',
            data: { name : name, content : content},
            dataType: 'json'
        });
}
toHo
  • 398
  • 5
  • 28