Support the ongoing development of Laravel.io →
posted 2 years ago
Blade
Last updated 2 years ago.

shihadop liked this thread

1
moderator

Jquery is client side but blade is serverside. That means you can add a javascript variable in your blade and use it with jquery. But you can't use jquery to set a blade variable directly.

You can use a GET variable to set a serverside variable and use it in your blade.

shihadop liked this reply

1

I'm a beginner, kindly inform how use GET variable to set a serverside variable and use it in blade

shihadop liked this reply

1
    public function index(Request $request)
    {
        $name = $request->input('name');
        return view('index',['name' => $name]);
    }

Check this code snippet. All your GET variables will be available in $request and can be access as $request->input('variable_name').

Then you can simply pass your server-side variable to your blade file.

As the blade file is just a PHP file, you can directly access the get variable using $_GET['variable_name']

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shihad shihadop Joined 24 Apr 2022

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.