Here is a demonstration of how I achieved this
Maybe I'll be late. This is just a sample code to help understand the people who visit this question. Hope this helps everyone who visits here.
in my routes.php I define a named route
Route::post('getLocation',array(
'as'=>'getLocation','uses'=>'FrontController@getLocation')
);
somehtmlform.blade.php
{!! Form::open() !!}
{!! Form::text('input-name',null,array('class'=>'form-control search-input','data-url'=> URL::route("getLocation") ))
{!! Form::close() !!}
my search.js URL- URL
$('.search-input').each(function(){
$(this).on('change',function (e) {
search(this)
});
});
function search(self) {
var query = $(self).val();
$.ajax({
url: $(self).attr('data-url'),
type: 'post',
data: {'q':query, '_token': $('input[name=_token]').val()},
success: function(data){
console.log(data);
},
error: function(data){
}
});
}