jeudi 23 mai 2019

How can I use a controller to execute a function in laravel without going to another page using the route?

I want to use a button in my website .When the button is pressed ,particular function will be executed. I can do it using route and controller.But in this case I have to use the name of another page and the website displays another blank page. I want that when the button is pressed, just the function will be executed and the display will remain same.

in the view page :
 <html>
    <body>
    <a href="" class="button">Link Button</a>
  </body>
 </html>
 in the controller :
  <?php

 namespace App\Http\Controllers;

 use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
 use Illuminate\Support\Facades\DB;

 class pagecon extends Controller
 {

 public function insert()
 {
    DB::insert('insert into abc (id, name) values (?, ?)', [2, $a]);


}
}
in the route:
 Route::get('abc', 'pagecon@insert');

In the database the values are inserted but the page 'abc' remains blank whether I use any css/html or not. As a recommendation ,I need some rich but easy tutorials link for laravel. I have searched in google but could not find proper answers for various problems.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/30FPcvq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire