Laravel Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6|
Lessons:-AJAX Content

22.5 Detecting an AJAX Request
Sometimes its useful to within the route whether a request has been made using AJAX.
Fortunately Laravel provides a method to detect AJAX requests. Let’s take a look.
1 <?php
2
3 // application/routes.php
4 Route::get('content', function() {
5
6 // check to see if the request is
7 // an AJAX one.
8 if (Request::ajax())
9 {
10 // provide the ajax content
11 return View::make('only_content');
12 }
13
14 // provide the full content
15 return View::make('content_with_layout');
16
17 });
The Request::ajax() returns a boolean true if the request is an AJAX request, and boolean
false if not.I would like to say thanks to the following people for buying a copy of Code Happy, thanks!
• William Manley
• Nate Nolting
• Jorijn Schrijvershof
• Caleb Griffin
• Florian Uhlrich
• Stefano Giordano
• Simon Edwards
I’d also like to say thanks to everyone that sent kind emails about the book, thanks for all the
support!

 

 

 
 
 

osdyui

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)