Skip to content Skip to sidebar Skip to footer

Bootstrap 2.2 Typeahead Issue

I am using the following code to get suggestion list when I type on my text box. JS $('#address').typeahead({ source: function(query,typeahead){ $.ajax({

Solution 1:

what is typeahead ? you obviously needs to do something with it before invoking the process member. ( instanciation , whatever typeahead is supposed to be ).

EDIT 1 :

source: function(query,callback/** you need that to execute something after the XMLHttp request has returned**/){ 
        $.ajax({
            url: "http://localhost/disc/autocomplete/"+query,
            type: "GET",
            dataType: "JSON",
            async: true,
            success: function(data){
                /** execute the callback here do whatever data processing you want before**/
                callback(data); 
            }
        });
    },

in functional programming it is called continuation ( like a GOTO instruction ).

EDIT 2 :

you do not decide what callback is , callback is function so dont try to do anything else than calling it with the data you received. Again , callback is a GOTO like instruction , it is a continuation , you dont control it. you need to execute it with data as parameter.


Post a Comment for "Bootstrap 2.2 Typeahead Issue"