提问人:DevLeo 提问时间:5/29/2021 更新时间:5/29/2021 访问量:49
jQuery UI 自动完成解析 json 数据
jQuery UI Autocomplete parsing json data
问:
我正在尝试将自动完成添加到我的搜索输入中,这是我的json:
json={"explains":[],"count":15,"quotes":[{"exchange":"NMS","shortname":"Apple Inc.","quoteType":"EQUITY","symbol":"AAPL","index":"quotes","score":8.85572E7,"typeDisp":"Equity","longname":"Apple Inc.","isYahooFinance":true},{"exchange":"MEX","shortname":"APPLE INC","quoteType":"EQUITY","symbol":"AAPL.MX","index":"quotes","score":20671.0,"typeDisp":"Equity","longname":"Apple Inc.","isYahooFinance":true}]}
我正在尝试创建一个表格,其中每行都有交易所,简称,符号我使用了这个脚本:
<script>
$(function() {
$("#search").autocomplete({
source : function(request, response) {
//Fetch data
$.ajax({
type: "POST",
url : "http://localhost:5000/search",
dataType : "json",
cache: false,
data : {
q : request.term
},
success : function(data) {
alert(data);
//How parse the data here to create the table?
response(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus + " " + errorThrown);
alert(textStatus + " " + errorThrown);
}
});
},
minLength : 2
});
});
</script>
如何解析json并创建包含元素的表?我被困在这里。有什么帮助吗?
答: 暂无答案
评论