Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear the cache for jquery ui autocomplete

I think I have read every stackoverflow and google result available on this issue and they all seem to refer to the first jquery autocomplete plugin and not the current jquery ui autocomplete.

What is the method for forcing the autocomplete results to update from the data source instead of the cached list?

like image 442
coder Avatar asked May 23 '12 18:05

coder


People also ask

How do you clear autocomplete value?

You can clear the text inside the SfAutoComplete control by assigning the String. Empty or using the Clear() method in SfAutoComplete.

What is jQuery ui autocomplete?

Autocomplete mechanism is frequently used in modern websites to provide the users a list of suggestion while typing the beginning word in the text box. It facilitates the user to select an item from the list, which will be displayed in the input field.

How can create autocomplete search box in jQuery?

Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })


1 Answers

The jquery ui autocomplete does not do any caching. The caching is happening at the browser level. To prevent it from happening, use $.ajaxSetup.

$.ajaxSetup({ cache: false });

You could also instead supply a function to the source option that does the ajax request for you with cache: false if you don't want to disable caching globally.

source: function(request, response) {
    $.ajax({
        url: "url.php",
        dataType: "json",
        cache: false,
        type: "get",
        data: { term: request.term }
    }).done(function(data) {
        response(data);
    });
}
like image 109
Kevin B Avatar answered Sep 20 '22 18:09

Kevin B