How to pass dyanamic parameters in ajax autocompelete query
I am using autocomplete functionality found at http://www.devbridge.com/projects/autocomplete/jquery/. 开发者_Go百科In addition to the text in the autocompelete text box, i would like to pass additional information, like selected states and highways. Following is the code I have. I am getting the text value in the textbox in the MVC action, but not the params. Can you please check what I am doing wrong.
var a = $('.exit-filters div.filters input#Exit').autocomplete2({
serviceUrl: $('.exit-filters input#exit-autocomplete-link').val(),
minChars: 1,
maxHeight: 300,
width: 70,
params: { highWays: JSON.stringify($('div.highway-filters input[type="checkbox"]:checked').attr('value')), states: JSON.stringify($('div.state-filters input[type="checkbox"]:checked').attr('value')) },
zIndex: 9999,
deferRequestBy: 0, //miliseconds
noCache: false, //default is false, set to true to disable caching
// callback function:
onSelect: function(value, data) { $('.exit-filters div.filters input#Exit').val(data); }
});
Actually more a comment (but I'm not yet cool enough ;-)
Have you checked with firebug if the additional params are sent to the server?
精彩评论