Getting data from another page
In our application, there may be times when we need to access some HTML from another page. Using Laravel and jQuery, we can accomplish this easily.
Getting ready
For this recipe, we just need a standard Laravel installation.
How to do it...
To complete this recipe, follow the given steps:
Open the
routes.php
file:Route::get('getting-data', function() { return View::make('getting-data'); }); Route::get('tab1', function() { if (Request::ajax()) { return View::make('tab1'); } return Response::error('404'); }); Route::get('tab2', function() { if (Request::ajax()) { return View::make('tab2'); } return Response::error('404'); });
In the
views
directory, create a file namedtab1.php
:<h1>CHAPTER 1 - Down the Rabbit-Hole</h1> <p> Alice was beginning to get very tired of sitting by her sister on the bank,and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations...