DEV Community

IRAWAN
IRAWAN

Posted on

passing data from laravel view to controller via ajax onchange event

The easiest way is to get the data in Laravel Request. At least that's how I do it.

So your route shouldn't contain any parameter for that.

Your route will look like this:

Route::get('get-data-by-id', 'PlotController@getData')->name('get.data.by.id');

Your ajax should be like this:

$(document).on('change', '#sel_test',function(){
    var testId = $(this).val();
    $.ajax({
        type:'GET',

Oldest comments (0)