Javascript 如何在php中从数据库中获取搜索数据

Javascript 如何在php中从数据库中获取搜索数据,javascript,php,jquery,Javascript,Php,Jquery,在我的代码中有一个divTextBoxContainer。现在我希望当我在脚本inputbox中单击DynamicTextBox时,它会显示数据库中已经存在的搜索值。我已经尝试过自动完成,但它不工作 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.

在我的代码中有一个div
TextBoxContainer
。现在我希望当我在脚本
inputbox
中单击
DynamicTextBox
时,它会显示数据库中已经存在的搜索值。我已经尝试过自动完成,但它不工作

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

    <script>
    $(function() {
      $("#btnAdd").bind("click", function() {
        var div = $("<div />");
        div.html(GetDynamicTextBox(""));
        $("#TextBoxContainer").append(div);

      });
       $( "#DynamicTextBox" ).autocomplete({
          source: 'search1.php'

      });

      $("#btnGet").bind("click", function() {
        var values = 
          $.map($("input[name=DynamicTextBox]"), function(el) {
            return el.value
          }).join(",\n");
        $("#anotherTextbox").val(values);
      });
      $("#btnGet").bind("click", function() {
        var values = 
          $.map($("input[name=DynamicTextBox1]"), function(el) {
            return el.value
          }).join(",\n");
        $("#anotherTextbox1").val(values);
      });
      $("body").on("click", ".remove", function() {
        $(this).closest("div").remove();
      });

    });

    function GetDynamicTextBox(value) {
      return '<input name = "DynamicTextBox" style="width:280px;margin-left:10px;" id="DynamicTextBox" class="skills" type="text" value = "' + value + '" />&nbsp;' + '<input style="width:280px;" name = "DynamicTextBox1" type="text" value = "' + value + '" />&nbsp;' +
        '<span type="button"  class="remove glyphicon glyphicon-remove"></span>'
    }
    </script>

<html>
 <div id="TextBoxContainer"></div>
</html>

$(函数(){
$(“#btnAdd”).bind(“单击”,函数(){
var div=$(“”);
div.html(GetDynamicTextBox(“”);
$(“#TextBoxContainer”).append(div);
});
$(“#DynamicTextBox”).autocomplete({
来源:“search1.php”
});
$(“#btnGet”).bind(“单击”,函数(){
var值=
$.map($(“输入[name=DynamicTextBox]”),函数(el){
返回el.value
}).join(“,\n”);
$(“#另一个文本框”).val(值);
});
$(“#btnGet”).bind(“单击”,函数(){
var值=
$.map($($(输入[name=DynamicTextBox1]),函数(el){
返回el.value
}).join(“,\n”);
$(“#另一个文本框1”).val(值);
});
$(“body”)。在(“单击”,“删除”,函数()上){
$(this).closest(“div”).remove();
});
});
函数GetDynamicTextBox(值){
返回“”+“”+
''
}

请尝试使用简单的ajax功能为什么要使用复杂的方法我不知道如何执行此操作..请建议..请尝试在google中使用phppost中的ajax搜索您的代码。