title: AJAX function always return html code in response on success
body: <p>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</p>
  
  <p>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</p>
  
  <p>Here is my controller function that the route requesting:</p>
  
  <pre><code>public function seen()
  {
      $user = User::find(Auth::user()-&gt;id);
  
      $notifications = $user-&gt;notification;
      foreach($notifications as $notification){
          $notification-&gt;seen = 1;
          $notification-&gt;save();
      }
  
      return response()-&gt;json(['status' =&gt; 'seen']);
  }
  </code></pre>
  
  <p>Here is the function route:</p>
  
  <pre><code>Route::get('/seen', 'CustomAuth\AuthController@seen')-&gt;middleware('authUser');
  </code></pre>
  
  <p>And finally the AJAX function:</p>
  
  <pre><code>    function seen(){
          let url = '/seen';
          $.ajax({
              type: 'GET',
              url: url,
              success: function (data) {
                  console.log(data);
              },
              error: function (data) {
                  console.log(data);
              }
          });
      }
  </code></pre>
  
  <p>Response I get when i set contenType to text:</p>
  
  <p><img src="https://i.stack.imgur.com/EwcJ8.jpg" alt="Response Headers"></p>
  
  <p>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</p>