ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯系官方銷售客服

1835022288

028-61286886

投訴 分享 在任意頁面、任意位置,通過Ajax處理搜索框,不跳轉獲取搜索結果 3 0
sloafer 免費用戶 2022-03-25 09:37:00 私信
迅睿CMS版本:4.5.0 #搜索關鍵詞 #return

簡單粗暴:在任意頁面、任意位置,通過Ajax處理搜索框,不跳轉獲取搜索結果

再通過Jquery直接Append到自己想要的位置。

思路:

創建一個只有(搜索結果)的search.html模板,里面還按照正常的搜索結果標簽寫法正常寫就行。

注意:不需要有其它的header和footer還有頁面中其它的html代碼。因為我們只需要這一部分就可以了。

{search module=MOD_DIR id=$searchid total=$sototal order=$params.order catid=$catid page=1 pagesize=5000 urlrule=$urlrule return=rs}
<li>
  <div class="shang">{$rs.title}</div>
  <div class="xia">{$rs.description}</div>
</li>
{/search}

在任意位置的搜索框(搜索按鈕)上面綁定JS事件

<script>
$(document).ready(function () {
    $(".search_btn").click(function(){
      var keyword = $(".search_text").val();
      if(keyword == ''){
        layer.msg('請輸入搜索關鍵詞',{time:1000});
        $(".search_text").focus();
        return false;
      }else{
        $.ajax({
           type: "GET",
           url: "index.php?s=shop&c=search&catid=15&keyword="+keyword+"&ajax_page=search.html",
           dataType: "text",
           success: function(html){
            $("#content_list").html(html);
          }
       });
      }
    });
});
</script>

就這樣就可以了。Ajax成功后的html其實就是你search.html模板里面的內容。直接顯示在對應的位置(一般是搜索框下面)即可。

就是這么簡單粗暴。太復雜的咱也不會。

解決方案