Php 使用JQuery自动完成的搜索功能

Php 使用JQuery自动完成的搜索功能,php,jquery,mysql,autocomplete,Php,Jquery,Mysql,Autocomplete,我正在从事一个项目,该项目涉及为字典数据库创建一个接口。我能够创建一个简单的搜索栏,可以提取正确的信息。之后,我能够使用jQuery为文本框实现自动完成功能。现在,我的搜索功能有问题。如果我提交表单,它会重定向到相应的脚本,但不会将文本框值发送到脚本 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>JQuery autocomplete example w

我正在从事一个项目,该项目涉及为字典数据库创建一个接口。我能够创建一个简单的搜索栏,可以提取正确的信息。之后,我能够使用jQuery为文本框实现自动完成功能。现在,我的搜索功能有问题。如果我提交表单,它会重定向到相应的脚本,但不会将文本框值发送到脚本

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JQuery autocomplete example with database accessing</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css">
            input.submit {
            width:30px;
            height:30px;
            cursor:pointer;
            background-image:url('../search-button.jpg');
        </style>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script>
    $(function() {
        $( "#searchbox" ).autocomplete({
            source: "data.php",
            minLength: 1
        });
    });
    </script>
</head>
<body bgcolor="#E6E6FA">
        <div style="background-color:#d4e7b2;text-align:left">
            <form action="../test.php" method="get" style="margin-left:1cm;">
                <div class="ui-widget">
                    <input id="searchbox"/>
                    <input class="submit" type="submit" value="" style="position:absolute;margin:0px 0 0 0px;"/>
                </div>

            </form>
            <br>
        </div>
    </body>
</html>

JQuery自动完成数据库访问示例
输入。提交{
宽度:30px;
高度:30px;
光标:指针;
背景图像:url('../search button.jpg');
$(函数(){
$(“#搜索框”).autocomplete({
资料来源:“data.php”,
最小长度:1
});
});

Autocomplete工作得非常出色,但按下搜索按钮会导致页面重定向到“/test.php?”而没有定义GET变量


非常感谢所有帮助!

您需要将名称添加到您的
搜索框中。
改变



搞定了!非常感谢!
<input id="searchbox"/>
<input name="searchbox" id="searchbox" />