hardeepcoder's avatar

I am successfully pass start and end price range with ajax get request but can not return in right way

Here i am trying fetch products with pass price range inputs to controller function. my js code

 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);
        }

    });
 }

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); // now we are fetching all products
        return view('front.shop', compact('Products'));
    }

view - inputs

                                    <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>
0 likes
1 reply

Please or to participate in this conversation.