gpt4 book ai didi

jquery - 维基百科 API 使用 Json 自动完成

转载 作者:行者123 更新时间:2023-12-01 04:24:17 24 4
gpt4 key购买 nike

如何在 jQuery 自动完成中实现它?

    $("#searchForm input").autocomplete({
source: function (request, response) {
$.ajax({
url: "http://en.wikipedia.org/w/api.php",
dataType: "jsonp",
data: {
maxRows: 10,
},
});
},

});

最佳答案

编辑:

如果你看this example ,您将看到带有 jsonp 示例的远程调用

查看示例的源代码和 success 函数。看起来他们正在映射 jsonp 字段以根据自动完成所需的数据使用数据。使用 fiddler 查看示例中的 json。

success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}

关于jquery - 维基百科 API 使用 Json 自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7835976/

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