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
I'm a beginner, kindly inform how use GET variable to set a serverside variable and use it in blade
shihadop liked this reply
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']
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community