I am using a autocomplete jquery. Code I am suing is something like this:
$(fun开发者_开发知识库ction() {
$( "#search").keyup(function(){
var cat=$("#categoryTag option:selected").text();
var url = "${resource.path}.suggestion.$"+this.value+".$"+cat+".json";
$(this).autocomplete({
source: url,
minLength: 2,
appendTo: "#search_results_div"
});
});
It is working fine, but The url I am getting is something like this http://servername/pagename/suggestion.textboxValue.dropdownValue?term=textBoxVale
My question is How can I avoid the query string as I want my url like this http://servername/pagename/suggestion.textboxValue.dropdownValue
Please give me pointers. Thanks in advance
source
can be a callback in which you can ajax any url you want:
$("#search").autocomplete({
source: loadFromAjax,
minLength: 2,
appendTo: "#search_results_div"
});
function loadFromAjax(request, response) {
$.ajax({
url: '/your/url/here/' + encodeURIComponent(request.term)),
dataType: 'json',
success: function(data) {
// you can format data here if necessary
response(data);
}
});
}
精彩评论