I've been attempting to incorporate callbacks to handle Ajax requests in my Laravel code, but I'm encountering some issues. Could someone please explain the concept of callbacks and assist me in integrating them successfully?
function sendImageToController(callback){
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name="csrf-token"]').attr('content') }
});
$.ajax({
url: "{{route('HeatMap.moveToStorage')}}",
data: {
"imgUrl": imgUrl,
"targetHeatMap": myMap
},
type:'post',
success:function(response){
if(!window.location.hash) {
// alert('Please Wait Loading');
// window.location = window.location + '#loaded';
// window.location.reload();
}
console.log("correct");
console.log(response);
},
error:function(e){
console.log(e);
},
});
}