jQuery UI otomatik tamamlama özelliğini kullanarak önbelleğe almayı deniyorum. İşte
$('#searchbox').autocomplete({
source: function(request, response) {
if (xhr === lastXhr) {
response($.map(data, function(item) {
return {
label: item.NAME + (item.PRFNM ? ' (' + item.PRFNM + ')' : '') + ', ' + item.JOBTITLE,
value: item.NAME
};
}));
}
});
}
});
örneğe bakarak çalışmak için önbelleğe alma benim girişimi: jQuery 1.4.4 ve UI kullanıyorum 1.8.6 Burada
Çalıştığım var temel kodudur
var cache = {},
lastXhr;
$('#searchbox').autocomplete({
source: function(request, response) {
var term = request.term;
if (term in cache) {
response($.map(cache[term], function(item) {
return {
label: item.NAME + (item.PRFNM ? ' (' + item.PRFNM + ')' : '') + ', ' + item.JOBTITLE,
value: item.NAME
};
}));
}
lastXhr = $.getJSON("getdata.php", request, function(data, status, xhr) {
cache[term] = $.map(data, function(item) {
return {
label: item.NAME + (item.PRFNM ? ' (' + item.PRFNM + ')' : '') + ', ' + item.JOBTITLE,
value: item.NAME
};
});
if (xhr === lastXhr) {
response($.map(data, function(item) {
return {
label: item.NAME + (item.PRFNM ? ' (' + item.PRFNM + ')' : '') + ', ' + item.JOBTITLE,
value: item.NAME
};
}));
}
});
}
});
Dışarıya giren var mı?
Sorun nedir? –
Olması gerektiği gibi önbelleğe alma değil. – nolabel