In laravel 5.8 project I am trying to use JQuery AJAX function to send a get request to one of project routes url the status of response is 200 which means that the request executed successfully but every time the function return the current view HTML in response
I tried to remove all the code in my php function and return only a JSON response but still getting HTML I also tried to change data type to JSON or text and setting cache to false but the response still the same I even tried to comment all the function the route requesting and the same response always come out I also tried many other solutions offered here or on other sites but no way to solve it
Here is my controller function that the route requesting:
public function seen()
{
$user = User::find(Auth::user()->id);
$notifications = $user->notification;
foreach($notifications as $notification){
$notification->seen = 1;
$notification->save();
}
return response()->json(['status' => 'seen']);
}
Here is the function route:
Route::get('/seen', 'CustomAuth\AuthController@seen')->middleware('authUser');
And finally the AJAX function:
function seen(){
let url = '/seen';
$.ajax({
type: 'GET',
url: url,
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
}
Response I get when i set contenType to text:

I expect that I would get a JSON response that I am try to return within the function but I suppose that the request do not reach the function and the problem is within the ajax request
{readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}@NiketJoshi