我使用的是语义用户界面,更具体地说是ui fluid seach
。我已声明如下:
<div id="inputIDtextfield" class="ui fluid search" style="width: 250px">
<div class="ui icon input">
<input id="inputValue" style="width: 250px" class="prompt" type="text" placeholder="Onekey_ID">
<i class="search icon"></i>
</div>
<div class="results"></div>
</div>
我需要向RESTful server
发送请求,并将搜索查询作为正文的一部分,这就是问题所在 - 我不知道如何检索搜索查询。我试着如下:
$('#inputIDtextfield')
.search({
minCharacters: 3,
searchOnFocus: false,
searchDelay: 500,
apiSettings : {
url : '/rest/get-hcp-suggest',
method: 'POST',
data: JSON.stringify({
'search': document.getElementById('inputValue').value
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
onResponse: function(response){
console.log(response);
var convertedResponse = {
results : []
};
// translate response to work with search
$.each(response, function(index, item) {
// add result to category
convertedResponse.results.push({
title : item.name,
description : item.onekey_id,
});
});
return convertedResponse;
},
},
});
}
但在这一部分:
data: JSON.stringify({
'search': document.getElementById('inputValue').value
}),
document.getElementById('inputValue').value
始终为空。
那么如何检索搜索查询呢?
答案 0 :(得分:1)