DEV Community 👩‍💻👨‍💻


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('');

Your ajax should be like this:

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

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.