autocomplete配合ajax进行查询

autocomplete配合ajax进行查询

作者:LAMP小白  点击:2014  发布日期:2013-05-13 16:06:55  返回列表

直接上代码 以后备用


<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
        <script src="./jquery-1.7.1.min.js"></script>
        <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    </head>
    <body>
        <input type="text" id="search" />
    </body>
    <script>
        $(function() {
            $( "#search" ).autocomplete({
                source: function( request, response ){
                    $.get('search.php', { term:request } , function(data){
                        response( $.map( data, function( item ) {
                            return {
                                value: item.value
                            }
                        }));
                    }, 'json')
                }
            });
        });
    </script>
</html>




上一篇:解决named[7780]: network unreachable resolving 下一篇:快递查询API
0