开发者

autocomplete jquery

开发者 https://www.devze.com 2023-03-26 13:08 出处:网络
I am using a autocompletejquery. Code I am suing is something like this: $(fun开发者_开发知识库ction() {

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);
        }
    });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消