jQuery Autocomplete using extraParams to pass additional GET variables

后端 未结 13 747
独厮守ぢ
独厮守ぢ 2021-01-31 17:23

I am referring specifically to the jQuery Autocomplete v1.1 plugin by Jörn Zaefferer [source: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/] as there seems to

13条回答
  •  天涯浪人
    2021-01-31 17:59

    You can use the built in jquery ui autocomplete like so:

              $(function() {
             $("#BurroughName").autocomplete({
                    minLength: 0,
                    source: function( request, response) {
                                $.ajax({
                                            url: "/JsonData/GetBurroughFromSearchTermJson",
                                            dataType: "json",
                                            data: {
                                                        term: request.term,
                                                        CityId: $("#CityId").val()
                                            },
                                            success: function( data ) {
                                                        response( data );
                                            }
                                });
                    },                  
                    select: function( event, ui) {
                        $("#BurroughId").val(ui.item.id);
    
                        if (ui.item.id != null) {
                             var cityId = $('#CityId').val();
                            $.getJSON("/AdSales/City.mvc/GetCityJSONListFromBrand", { burroughId: ui.item.id }, function(data) {
                                 $("#CityId").fillSelect(data);
                                 var foo = $("#CityId option[value=" + cityId + "]");
                                 if(($("#CityId option[value=" + cityId + "]").length > 0) && cityId != "")
                                 {
                                     $("#CityId").val(cityId);
                                 }
                            });
                        }
                        $('#burroughSpinner').fadeOut('slow', function(){});
                    }
             });
         });
    

    Here's their jsonp example: http://jqueryui.com/demos/autocomplete/#remote-jsonp

提交回复
热议问题