JSFiddle - React, Tailwind, and code Playground

by cjblomqvist

HTML

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<div class="ui-widget">
    <label for="birds">Countries: </label>
    <input id="birds" />
</div>

JavaScript

$(function() {
    var cache = {};
    $( "#birds" ).autocomplete({
        minLength: 2,
        source: function( request, response ) {
            var term = request.term;
            if ( term in cache ) {
                response( cache[ term ] );
                return;
            }

            $.getJSON( "http://www.bbweb.se/files/data.php?query=" + term, request, function( data, status, xhr ) {
                cache[ term ] = data;
                response( data );
            });
        }
    });
});