Autocomplete Search using jQuery and Wikipedia OpenSearch API
In web design, the autocomplete feature is a common one. When the user types some value in the search text box, it automatically shows a relevant list of suggestions in the form of dropdown that can be chosen by the user easily. For jQuery Autocomplete feature, refer this article.
Approach: In this article, we use the Wikipedia Opensearch API and the jQuery Autocomplete UI. Basic HTML code is used for the user interface for keyword search in an input text box. While using the jQuery code, the search request is sent to Wikipedia which in turn returns a list of suggestions based on user entry. The data response is in JSON format.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.
Syntax: Wikipedia URL for API
Setting up environment: For more option settings
The developer can refer the above URL link and make use of many option settings depending on the application’s need.
jQuery and jQuery UI libraries: The following files are used in the code.
<link href=” https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css” rel=”stylesheet” type=”text/css”/>
Example: The following example demonstrates the autocomplete search feature by using Wikipedia OpenSearch API and jQuery. The HTML code provides a normal search input box which gives suggestions when the user types some search texts.