PHP, MYSQL Autocomplete does not working

前端 未结 4 1783
我在风中等你
我在风中等你 2021-01-28 04:16

I want to make auto complete text box for select employee names from the database. I don\'t have fair idea about that. But I tried to make it as following.

autocomplete

4条回答
  •  无人及你
    2021-01-28 04:46

    you need to bind your input to the onchange action

    Use this

    $(document).ready(function(){
        $("#typeahead").change(function(event){
            var query = document.getElementById('typeahead').value;
            jQuery.ajax({
                url: 'autocomplete.php',
                type:'POST',
                data:{'query':query},
                dataType: 'JSON',
                cache:false,
                success:function(data){
                    // Do Anything You want here
                },
                error:function(){
                    // Do something else here
                }
            });
        });
    });
    

提交回复
热议问题