I use Symfony 5, but I can not make an AJAX call because it says that "$.ajax is not a function". I installed jQuery using composer require components/jquery and it does not work. I took the jquery directory from /vendor/components and I pasted it into the public directory, into a directory called "assets" and then I tried to include it with:
<script type="text/javascript" src="{{asset('assets/jquery/jquery.js')}}">
But nothing works. The script is:
<script type="text/javascript">
let id = 1;
$(document).ready(function() {
$.ajax({
url: "/getBuildingDetails",
type: "GET",
data: id,
success: function (data) {
console.log(data);
},
error: function () {
console.log("Something went wrong");
}
});
}
);
</script>
I searched the error and the only thing was to change jquery.slim.min.js to jquery.min.js, but I already use jquery.min.js(at least I am trying to use it...). I tried with the cdn, but nothing works. I am new, I don't have experience... Do you have a video or an article that can help me? Thank you!