<!DOCTYPE html> <!--[if lt IE 9]> <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <html> <head> <meta charset="utf-8"> <title>jQuery UI 測試</title> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/hot-sneaks/jquery-ui.css" rel="stylesheet"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script> <style> article,aside,figure,figcaption,footer,header,hgroup,menu,nav,section {display:block;} body {font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;} </style> </head> <body> 股名或股號 : <input id="auto1" type="text" /> <script language="JavaScript"> $(document).ready(function(){ $("#auto1").autocomplete({source: function(request, response) { $.ajax({ url: 'get_stocks_list_4.php', data: {term: request.term}, success: function(data) { //alert(data); var result=$.map(data, function(item){ var label=item.label + " (" + item.value + ")"; var value=item.value; return {label: label, value: value}; } //var result=["1","2"]; response(result); } //end of function }); //end of ajax } //end of function }); }); </script> </body> </html>