Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

Closed Issue: Caching bug if making same call to different webURLs [10167]

$
0
0
Hi Marc,

I'm working on a cascading autocomplete solution where the user enters a site URL in one input and then types a list/library name in a second input. I'm using the URL from the first input as the webURL option to call "GetListCollection" and provide the results as a data source for the autocomplete feature.

I turned on caching to avoid making an AJAX request for every keystroke (HUGE performance increase, BTW), but I noticed a bug:

1. User enters URL in first input
2. User enters list name in second input (works as expected)
3. User changes URL in first input
4. User enters list name in second input, but the autocomplete data source is still using the first URL's cached results

The caching solution does not take into account which webURL is used. I patched the bug by including the ajaxURL variable in the key for the cache on lines 1207 and 1216 in 2013.01. I tested the patch with my solution and with SPCascadeDropdowns and everything worked as expected.

```
// Check to see if we've already cached the results
var cachedPromise;
if(opt.cacheXML) {
cachedPromise = promisesCache[msg + ajaxURL];
}

// If we don't have a completefunc, then we won't attempt to call it
var thisHasCompletefunc = $.isFunction(opt.completefunc);

if(typeof cachedPromise === "undefined") {

// Finally, make the Ajax call
promisesCache[msg + ajaxURL] = $.ajax({

```
Comments: Released in 2013.02

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>