Here I am trying fetch products with pass price range inputs to controller function
JS code :
<script>
function send() {
var start = $('#amount_start').val();
var end = $('#amount_end').val();
//var dataString = "start" + start;
$.ajax({
type: 'get',
url: 'shop',
data: "start=" + start + "&end=" + end,
success: function(response) {
console.log(response);
}
});
}
</script>
Controller
if ($request->ajax()) {
$start = $request->start;
$end = $request->end;
$Products = DB::table('products')->get();
return view('front.test')->with('Products', $Products);
} else {
$Products = DB::table('products')->paginate(6);
return view('front.shop', compact('Products'));
}
my input view:
<label for="amount">Price range:</label>
<input type="text" id="amount_start" name="start_price" value="70" />
<input type="text" id="amount_end" name="end_price" value="150" />
<div id="slider-range"></div>
<button onclick="send()">Click me</button>
via hardeepcoder