如何在laravel中单击时从ajax重定向到视图?

如何在laravel中单击时从ajax重定向到视图?,ajax,laravel,Ajax,Laravel,因此,我在laravel和$ajax中进行自动完成实时搜索 如何在单击中重定向到特定视图?我的意思是,当我点击其中一个结果时,它会将我发送到产品页面,现在它所做的只是重新加载页面…但当我点击搜索按钮时,它只返回到同一页面,URL地址没有任何变化。多谢各位 路线 blade.php <div class="vcenter-this"> <form action="" method="GET" autocomplete="off" no

因此,我在laravel和$ajax中进行自动完成实时搜索

如何在单击中重定向到特定视图?我的意思是,当我点击其中一个结果时,它会将我发送到产品页面,现在它所做的只是重新加载页面…但当我点击搜索按钮时,它只返回到同一页面,URL地址没有任何变化。多谢各位

路线

blade.php

    <div class="vcenter-this">
                  <form  action="" method="GET" autocomplete="off" novalidate="novalidate">
                  @csrf
                   <div class="input-group ml-3" style="max-width: max-content; margin-left: 
                    10px;">
                    <input type="text" class="form-control" value="<?= old('search'); ?>"  
                 name="search" id="search" class="form-control" placeholder="Search Item">
                   <span class="input-group-btn">
                   <input id="search-btn" type="submit" value="GO!" name="submit" 
                 class="btn btn-primary" >
        <i class="fa fa-search"></i>
  </span>
</div>

有一个显示所需视图的操作/路线,重定向到该路线可以给我一个例子吗?
    <div class="vcenter-this">
                  <form  action="" method="GET" autocomplete="off" novalidate="novalidate">
                  @csrf
                   <div class="input-group ml-3" style="max-width: max-content; margin-left: 
                    10px;">
                    <input type="text" class="form-control" value="<?= old('search'); ?>"  
                 name="search" id="search" class="form-control" placeholder="Search Item">
                   <span class="input-group-btn">
                   <input id="search-btn" type="submit" value="GO!" name="submit" 
                 class="btn btn-primary" >
        <i class="fa fa-search"></i>
  </span>
</div>
use Illuminate\Http\Request;
use DB;
use App\Search;
class SearchController extends MainController
{
    public function search($search)
    {
        if (isset($_GET['submit'])) {

            $search = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
            $search = trim($search);
        }
        if ($search) {
            $products = DB::table('products as p')
                ->join('categories as c', 'c.id', '=', 'p.categorie_id')
                ->select('p.ptitle', 'p.purl', 'c.curl')
                ->where('p.ptitle', 'like',  '%' . $search . '%')
                ->get()
                ->toJson();

            if ($products) {

             return $products;
            }
        }
    }
} 

Script.js

    $('#search').on('input', function () {

    var userSearch = $(this).val().trim();

    if (userSearch.length > 0) {

      $.ajax({
        type: 'GET',
        url:  BASE_URL + 'search/' + userSearch ,
        dataType: 'json',
        //data: { search: userSearch },
        success: function (products) {

          if (products) {

            var availableTags = [];

            products.forEach(function (products) {
              availableTags.push(products.ptitle);

            });

            $("#search").autocomplete({
              source: availableTags,

              select: function (event, ui) {
                $('#search-btn').on('click',function(products) {


***what commend should i put here ? *** 

***the destination url supposed to be like the line below ***

                   // window.location.href = BASE_URL + "shop/" + products.curl +  '/' + products.purl;




                  });
              }
            });


          }

        }
      });

    }

  });