]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete cache demo: Let the widget handle request synchronization. Fixes #8616...
authorScott González <scott.gonzalez@gmail.com>
Tue, 2 Oct 2012 14:21:52 +0000 (10:21 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 2 Oct 2012 14:21:52 +0000 (10:21 -0400)
demos/autocomplete/remote-with-cache.html

index 6f25c55349075ef614a8cbfed6d8b2f79e252ffe..bc1de7746232a7936151bcdc395307cc7ef71e67 100644 (file)
@@ -18,8 +18,7 @@
        </style>
        <script>
        $(function() {
-               var cache = {},
-                       lastXhr;
+               var cache = {};
                $( "#birds" ).autocomplete({
                        minLength: 2,
                        source: function( request, response ) {
                                        return;
                                }
 
-                               lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
+                               $.getJSON( "search.php", request, function( data, status, xhr ) {
                                        cache[ term ] = data;
-                                       if ( xhr === lastXhr ) {
-                                               response( data );
-                                       }
+                                       response( data );
                                });
                        }
                });