Laravel 5 Non Static Method Request::ajax() Should Not Be Called Statically

Diego Cortés
Diego Cortés
September 7, 2016
Laravel 5 Non Static Method Request::ajax() Should Not Be Called Statically

Hello everyone, today we will see how to solve the following error when using Request::ajax() to verify that the request is via ajax, the error is the following:

Non-static method Illuminate\Http\Request::ajax() should not be called statically

Solution:

The solution is very easy! Simply within our controller that we are using we must replace the line:

use Illuminate\Http\Request

by:

use Request;

Now it should work perfectly, at least for me :D, I hope it helps more than one.

Article information

Published: September 7, 2016
Category: Laravel Tutorials
Reading time: 5-8 minutes
Difficulty: Intermediate

Key tips

1

Take your time to understand each concept before moving on to the next one.

2

Practice the examples in your own development environment for better understanding.

3

Don't hesitate to review the additional resources mentioned in the article.

Diego Cortés
Diego Cortés
Full Stack Developer, SEO Specialist with Expertise in Laravel & Vue.js and 3D Generalist

Frequently Asked Questions

Categories

Page loaded in 34.88 ms