gpt4 book ai didi

jquery - 我如何从单独的文本框中的自动完成响应中获取 json 键和值。请看图片

转载 作者:行者123 更新时间:2023-11-28 01:07:51 25 4
gpt4 key购买 nike

enter image description here

请看图片你会明白...这张图片取自 chrome 开发工具,我正在控制台上打印 JSON 响应。

以下是自动完成代码...

$("#search-org").autocomplete({
width: 300,
max: 10,
delay: 100,
minLength: 1,
autoFocus: true,
cacheLength: 1,
scroll: true,
highlight: false,
source: function(request, response) {
$.ajax({
url : "../../SearchHelperController",
contentType : "application/json; charset=utf-8",
dataType : 'json',
type : 'GET',
cache : false,
data: {
searchKeyword: request.term,
searchType: $("#byName").val()
},
success: function(data, textStatus, jqXHR) {
console.log(data);
response(data);
},
error: function(jqXHR, textStatus, errorThrown){
console.log( textStatus);
}

});
},
select: function (event, ui) {
$("#org-id").val(ui.item.key);
},

});

html代码..

<div class="radio">
<label><input type="radio" id="byName" name="byName" value="OU" checked> By Name</label>
<input type="text" id="org-id">
</div>
<div class="form-group">
<input type="text" class="form-control" id="search-org">
</div>

最佳答案

@AhmadBamieh,感谢支持我解决了这个问题,这是代码,

HTML 代码

<form action="#">
<table align="center" style="padding-top: 5%">
<tr>
<td align="right">AutoComplete:</td>
<td><input id="autoText" name="autoText" autofocus/></td>

<td align="right">Key:</td>
<td><input id="key" /></td>
</tr>
</table>
</form>

JQuery 自动完成代码

$(document).ready(function() {          
var value;
$("#autoText").autocomplete({
width: 300,
max: 10,
delay: 100,
minLength: 1,
autoFocus: true,
cacheLength: 1,
scroll: true,
highlight: false,
source: function(request, response) {
$.ajax({
url : "../AutoCompleteController",
contentType : "application/json; charset=utf-8",
dataType : 'json',
type : 'get',
cache : false,
data: {
term : request.term,
},
success: function(data) {
value = data;
response(data);
},
error: function(jqXHR, textStatus, errorThrown){
console.log( textStatus);
}

});
},
select: function (event, ui) {
lable = ui.item.value;
$.each(value, function(key, value){
if(lable == value) {
$("#key").val(key);
}
});
},

});
});

关于jquery - 我如何从单独的文本框中的自动完成响应中获取 json 键和值。请看图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39012445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com