使用 jqueryui 自动完成时的附加参数
我希望向 jquery UI 自动完成请求添加一个附加参数,而不必将 json 返回嵌套在 ajax 调用中。我设想像下面这样工作,但是 data: 选项不会像普通的 jquery ajax 请求一样传递给 ajax 请求。
$("#div").autocomplete({
source: 'ajax.php',
minLength: 2,
data: '&action=getUserName',
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
}
});
tl;dr 我需要帮助将 &action=getUserName
传递给 ajax 以进行自动完成,最好不要将其嵌套在 ajax 回调中。
I'm looking to add an additional parameter to a jquery UI auto complete request without having to nest the json return in an ajax call. I would envision something like the following working, however the data: option is not passed over to the ajax request like it is on a normal jquery ajax request.
$("#div").autocomplete({
source: 'ajax.php',
minLength: 2,
data: '&action=getUserName',
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
}
});
tl;dr I need help passing &action=getUserName
over to the ajax for my autocomplete, preferably without nesting it in an ajax callback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
根据文档: http://docs.jquery.com/Plugins/Autocomplete /autocomplete#url_or_dataoptions
编辑:添加了基于 jquery autocomplete extraParams 的更正
Try this instead:
per docs: http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions
edit: added correction based on jquery autocomplete extraParams