In this tutorials we will share with you how to check request is ajax or not in laravel. some time we work with laravel API then it is help more. because help of this you can manage you API ajax request and web request in same controller so, you can manage you code very easy way.
You can check ajax request help of ajax() function in laravel.
Laravel Request class has many method to read HTTP request from the currenct request. ajax() one of them
public function index(Request $request)
{
if($request->ajax()){
return response()->json(['status'=>'Ajax request']);
}
return response()->json(['status'=>'Http request']);
}
public function index()
{
if($request->ajax()){
return response()->json(['status'=>'Ajax request']);
}
return response()->json(['status'=>'Http request']);
}
We hope these small tutorials help everyone. if you like this article then please comment below. Thanks..
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Google Bar Chart with Example VueJs
Today,I will learn you how to create Goo...How to Set CSS background-image Property Using jQuery
Use the jQuery CSS() Method To set th...How to Check If a Value Exists in an Array in JavaScript
Use the indexOf() Method You can use...jQuery Get Selected Option From Dropdown
In this article, we will share with you...Create a bootable USB stick on Ubuntu
To install operating system, first you n...