2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

how to use twitter bootstrap typeahead ajax example of autocomplete

 how to use  typeahead ajax for autocomplete feature.
userimage

To use autocoplete feature:

1: http://plugins.upbootstrap.com/bootstrap-ajax-typeahead

download the plugin

2: <input type="search" class="form-control"
                                id="autocompleteinputid" autocomplete="off">

add the input field where you want to use autcomplete feature.

3: $(function() {
    $("#autocompleteinputid")
    .typeahead(
            {onSelect : function(item) {
                     // onselect feature based on your requirement.
                });
                },
                ajax : {
                    url : "<the URL you want to trigger and get the data to display>",
                    timeout : 100,
                    displayField : "title",
                    triggerLength : 1,
                    method : "post",
                    preDispatch : function(query) {
                       // Before trigger to server if you wan to set any parameter.
                    },
                    preProcess : function(data) {
                       // after got the data from server if you want to do some operation on the data.
                    }
                }
            });
});

Done

        

Answer is