How to check request is Ajax or not in Laravel 5?

How to check request is Ajax or not in Laravel 5?

In this post, I will let you know how to determine request is ajax or not in Laravel 5.

Sometime you need to check if request is ajax then response data only and if request is not ajax then response complete view in your application.

By using ajax() method in Laravel, you can check request is ajax or not.

Laravel Request class has many method to read HTTP request for the current request. You can also check if request is over https or request has json content type.

You can use directly Request facade that grant you access to the current request or you can use instance of Request Class.

Example :

  1. public function index(Request $request)
  2. {
  3. if($request->ajax()){
  4. return response()->json(['status'=>'Ajax request']);
  5. }
  6. return response()->json(['status'=>'Http request']);
  7. }

  1. public function index()
  2. {
  3. if(Request::ajax()){
  4. return response()->json(['status'=>'Ajax request']);
  5. }
  6. return response()->json(['status'=>'Http request']);
  7. }

To determine if the request is over HTTPS :

  1. if (Request::secure())
  2. {
  3. //
  4. }

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
sohbet okey oyna
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat

viagra fiyatı

viagra 100 mg fiyat

viagra sipariş

orjinal viagra

viagra satın al

izmir escort