0

I am trying to make an Ajax call work in a click event but it is giving me an error:

$.ajax is not a function

My call:

module.exports.doaction = (Identifier) => {
    $(Identifier).modal('show');
    $(`${Identifier} a`).click((event) => {
        $.ajax({
            type: 'POST',
            url: '/action',
            data: event.target.id
        });
    });
};

What I am missing?

On my main page the script has been included:

<script src="code.jquery.com/jquery-3.1.1.slim.min.js"></script>
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Akki
  • 29
  • 7

1 Answers1

0

$.ajax is not a function means you didn't included jquery properly.

slim build of jquery doesn't include ajax function.

you can include jquery from

https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js

HerrGanzorig
  • 51
  • 1
  • 14