简体   繁体   English

具有JSON的自动完成的Jquery UI

[英]Autocomplete Jquery UI with JSON

This example works great for what I need: Codepen Example 此示例非常适合我需要的代码: Codepen示例

But I need to call city values from an external JSON. 但是我需要从外部JSON调用城市值。

How can I adapt this example to call an external JSON? 如何修改此示例以调用外部JSON? Something linke this: 链接到此:

 $.getJSON( "http://gd.geobytes.com/AutoCompleteCity?callback=?&q=" + request.term, function (data) { response(data); }); 

Thanks a lot! 非常感谢!

The method $.getJSON() will do exactly that. 方法$ .getJSON()可以做到这一点。 It's just shorthand syntax for $.ajax(). 这只是$ .ajax()的简写语法。 You can load the JSON from the external API and then run whatever comparsions/checks you need. 您可以从外部API加载JSON,然后运行所需的任何比较/检查。

http://api.jquery.com/jquery.getjson/ <- more examples and documentation http://api.jquery.com/jquery.getjson/ <-更多示例和文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM