基於jQueryUI和Corethink實現百度的搜尋提示功能_php執行個體

來源:互聯網
上載者:User

先給大家展示下效果圖:

 

目錄:

 

這裡是以corethink模組的形式,只需要安裝上訪問

index.php?s=/test/index

1.建好模組目錄,寫好模組的總體檔案

opencmf.PHP

<?phpreturn array(// 模組資訊'info' => array('name' => 'Test','title' => 'Test','icon' => 'fa fa-newspaper-o','icon_color' => '#9933FF','description' => 'Test','developer' => 'pangPython','website' => 'http://blog.csdn.net/u012995856/','version' => '1.3.0','dependences' => array('Admin' => '1.3.0',)),// 使用者中心導航'user_nav' => array(),// 模組配置'config' => array(),// 後台菜單及許可權節點配置'admin_menu' => array('1' => array('id' => '1','pid' => '0','title' => 'Test','icon' => 'fa fa-newspaper-o',),'2' => array('pid' => '1','title' => '內容管理','icon' => 'fa fa-folder-open-o',),));

2.寫控制器

IndexController

<?phpnamespace Test\Controller;use Think\Controller;use Home\Controller\HomeController;/****/class IndexController extends HomeController{public function index(){$this->display();}public function mydata($keyword){if ($keyword==11) {echo '["pangPython","HelloWorld"]';}else{echo '["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang","Fortran","Groovy","Haskell","Java","JavaScript","Lisp","Perl","PHP","Python","Ruby","Scala","Scheme"]';}}}

3.寫前台檔案

index.html

<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><link rel="stylesheet" href="http://cdn.bootcss.com/jqueryui/1.12.0/jquery-ui.css" media="screen" title="no title"></head><body><!-- Autocomplete --><h2 class="demoHeaders">Autocomplete</h2><div><input id="autocomplete" title="type "a""></div></body><script type="text/javascript" src="__PUBLIC__/libs/jquery/1.x/jquery.min.js"></script><script type="text/javascript" src="http://cdn.bootcss.com/jqueryui/1.12.0/jquery-ui.js"></script><script type="text/javascript">var url ="{:U('test/index/mydata')}";$( "#autocomplete" ).autocomplete({minLength: 2,source: function(request,response){$.getJSON(url,{keyword:request.term},function(data,status,xhr){response(data);});}});</script></html>

以上所述是小編給大家介紹的基於jQueryUI和Corethink實現百度的搜尋提示功能,實現一個類比後台資料登入的效果,希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.