mardi 2 octobre 2018

How to cal laravel route from js script file?

In my larabel 5.7 I have in routes/web.php :

Route::group(['middleware' => ['auth', 'isVerified'], 'prefix' => 'admin', 'as' => 'admin.'], function () {
    ...
    Route::get('get_system_info', [
        'as'   => 'get-system-info',
        'uses' => 'Admin\DashboardController@get_system_info']
    );

From my php code I can open this using "as" url from above as : return redirect()->route('admin.get-system-info');

But when I need to run this code in ajax from my .js file I make :

 var href= '/admin/get_system_info';
 $.ajax(
     {
         type: "GET",

My question is if there is a way to avoid using url "get_system_info" from my js file but to use "as" from my routes/web.php, like :

 var href= 'admin.get_system_info';
 $.ajax(
     {
         type: "GET",

If yes how ?

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire