I have recently started to learn Javascript and I am working on a small project. I am having an error stating "$.ajax is not a function". endpoint
, token
, and body
are defined variables.
var $ = require('jQuery');
$.ajax({
type: 'POST',
url: endpoint + token,
contentType: 'application/json',
data: JSON.stringify(body),
success: function(data, status) {
console.log(data);
console.log(status);
},
error: function(jqXHR, status, errorThrown) {
console.log(errorThrown);
console.log(status);
console.log(jqXHR);
}
});
Anyone see a problem with what I have?