Im sending data via AJAX from my Chrome-extension to my OctoberCMS controller.
How can I recognize in my Chrome-extension that the database operation was successful?
So the goal is that I can use the done()
in my AJAX call after a successful database update.
Do I have to return something from my controller?
Ajax from extension
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: "/saveData",
type: "POST",
dataType: "JSON",
data: { "data": data}
}).done(function((){//does nothing});
OctoberCMS Controller
function saveData(Request $request)
{
$data = post('data');
//do some actions with the data;
DB::table('users')->where(['id' => Auth::getUser()->id])->update(['data' => $data]);
}