尽管我们需要在selects change方法上调用setOptions方法,但该方法仍然有效。因此,将脚本更改为:
<script type="text/javascript">//<![CDATA[ var a = $('#q').autocomplete({ serviceUrl:'/search', delimiter: /(,|;)s*/, // regex or character maxHeight:400, width:325, zIndex: 9999, params: {entity_type:$('#top_search_select').val()}, deferRequestBy: 0, //miliseconds noCache: false, //default is false, set to true to disable caching onSelect: function(value, data){window.location.replace(data);}, }); a.setOptions({params:{entity_type:$('#top_search_select').val()}});//]]></script>和在文档就绪功能上添加以下内容:
$("#top_search_select").change(function() { a.setOptions({params:{entity_type:$('#top_search_select').val()}});});


