Laravel AJAX GET and show new data
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
# Mastering Dynamic Data Loading: Using Laravel AJAX GET Requests to Show New Data
As developers, we frequently encounter the challenge of creating dynamic user experiences where data is updated or fetched in real-time without forcing a full page reload. You’ve successfully mastered data submission using AJAX `POST` requests, but now you’re stuck on fetching and displaying the results using an AJAX `GET` request. This is a very common hurdle, and while the core concepts are simple, ensuring the communication between your frontend (JavaScript) and backend (Laravel) is flawless requires attention to detail regarding routing, response handling, and security.
This post will walk you through exactly how to correctly implement an AJAX GET request in a Laravel application to retrieve data from your database and dynamically inject it into the HTML structure. We will analyze the code snippets you provided and establish the best practices for this interaction.
## The Core Concept: GET vs. POST in AJAX
The fundamental difference lies in intent:
* **POST:** Used when sending *new* data to the server for creation or modification (e.g., submitting a form, saving an entry). This data is sent in the request body.
* **GET:** Used when requesting *existing* resources from the server (e.g., fetching a list of items, retrieving a specific record). This data is appended to the URL as query parameters.
Since you are trying to **show results** after an action, using `GET` is the correct approach because you are asking the server, "Give me the details for video ID X," rather than submitting new content.
## Step 1: Setting Up the Laravel Backend (Controller & Routing)
Your backend setup looks very solid. The key in a Laravel application is ensuring your route correctly maps to a controller method that returns data in a machine-readable format, typically JSON.
### The Route Setup
First, ensure you have a route defined in your `routes/web.php` file that points to your controller method. For the example provided:
```php
// routes/web.php
Route::get('/video/{video}/shownew', [VideoController::class, 'shownew'])->name('video.shownew');
```
### The Controller Logic
Your controller method correctly queries the database and returns a JSON response, which is exactly what your frontend JavaScript expects:
```php
// app/Http/Controllers/VideoController.php
use Illuminate\Support\Facades\DB;