I do not understand why I see it an error in the browser console.
Uncaught TypeError: $.ajax is not a function - I see this message
I only found advice that it is not the correct version of the library.
But I think my version is correct.
My code
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
<input type="button" id="id_name_task" value="Click" />
<script type="text/javascript">
$(document).ready(function() {
$("#id_name_task").click(function() {
var name_task = $(this).val();
console.log(name_task);
$.ajax({
type: 'GET',
async: true,
dataType: 'json',
url: '/validate_data/',
data: {
'name_task': name_task
},
success: function(data) {
if (data.is_taken) {
alert("A task with this name already exists.");
}
},
});
});
});
</script>