javascript - How to append params to ajax request in Select2? - Stack Overflow

i'm building a web app using Laravel, and i have to implement tag selection, like this one used by

i'm building a web app using Laravel, and i have to implement tag selection, like this one used by stackoverflow, loading options via ajax and if is not exist create it, i did choose Select2 jquery plugin, the problem i have with it, is cant get it to append parameters to the ajax url,

Route :

 /tags/{tag}

how can i append the term of select to my url ?

i'm building a web app using Laravel, and i have to implement tag selection, like this one used by stackoverflow, loading options via ajax and if is not exist create it, i did choose Select2 jquery plugin, the problem i have with it, is cant get it to append parameters to the ajax url,

Route :

 /tags/{tag}

how can i append the term of select to my url ?

Share Improve this question asked Nov 3, 2014 at 13:49 Iliyass HamzaIliyass Hamza 1,4053 gold badges17 silver badges30 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

In Select2 3.x, you can pass a function as the ajax.url option. It will be passed the current search term as the first parameter, which sounds like what you are looking for.

$element.select2({
   ...
    ajax: {
        url: function (term) {
            return '/tags/' + term;
        },
        ...
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745194299a4616015.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信