Console Error with Ajax: Referenceerror: $ Is Not Defined

Console Error with Ajax: Referenceerror: $ Is Not Defined

i have a problem with a little script on my html page. It's just a function which should be called by an onclick method in an a tag. It dont works. Everytime i click on the link in the browser the console says "ReferenceError: $ is not defined" and points on the third line of the code below.

<script>
    function del(urlToDelete) {
        $.ajax({
            url: urlToDelete,
            type: 'DELETE',
            success: function(results) {
                location.reload();
            }
        });
    }
</script>
4

4 Answers

You need to include jquery library for that.Like this. You need to include this 1st, then write $.ajax to execute.

<script src=""></script>

0

It looks like the jQuery libraries have not been included within your project.

<script src=""></script>

The above answers use http version,which might not be allowed at production ,alternatively use:

<script
          src=""
          integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
          crossorigin="anonymous"></script>

or visit:

1

When pulling sample code from Bootstrap (and possibly others), it's likely the slim version. This doesn't include ajax. Pick "uncompressed" or "minified" from .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.