Saturday, April 15, 2017

Laravel get and post to an external php controller with ajax

I am working on laravel project and i need to make AJAX post to custom function in laravel.

My question is where to put function.php and how to call and pass variables from js function inside view/template.blade file with AJAX?

Atm i have

  1. /app/develu/vathelper.php

  2. Inside autoload_classmap.php i have path to my function

'App\develu\vathelper' => $baseDir . '/app/develu/vathelper.php',

  1. Autoload_static.php

'App\develu\vathelper' => $baseDir . '/app/develu/vathelper.php',

  1. Routes.php

Route::get('/clients.vat', 'vathelper@vatcheck'); Route::post('/clients.vat', 'vathelper@vatcheck');

5.

    $.get('/clients.vat', function(){ 
    $('.p-test').log('response');
    });

My end goal is to make form and send data with post to a function inside helper and get response to js, and echo it inside table, the only thing i can't figure out is how to post and get inside laravel.



via Nikas Nikis

Advertisement