Skip to content

Commit 5a9905b

Browse files
committed
Merge pull request select2#1186 from barryhunter/patch-1
Allow overriding jquery's automatic cache-busting on ajax calls
2 parents 28f50c9 + f511d5a commit 5a9905b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

select2.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ the specific language governing permissions and limitations under the Apache Lic
346346
* @param options.url url for the data
347347
* @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
348348
* @param options.dataType request data type: ajax, jsonp, other datatatypes supported by jQuery's $.ajax function or the transport function if specified
349+
* @param options.cache set to true to disable jquery's cache-busting url parameters
350+
* @param options.jsonpCallback set to override the jquery callback function - useful in conjunction with options.cache
349351
* @param options.traditional a boolean flag that should be true if you wish to use the traditional style of param serialization for the ajax request
350352
* @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
351353
* @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
@@ -370,6 +372,8 @@ the specific language governing permissions and limitations under the Apache Lic
370372
data = options.data, // ajax data function
371373
url = ajaxUrl, // ajax url string or function
372374
transport = options.transport || $.ajax,
375+
cache = options.cache || false,
376+
jsonpCallback = options.jsonpCallback || undefined,
373377
type = options.type || 'GET', // set type of request (GET or POST)
374378
params = {};
375379

@@ -391,7 +395,8 @@ the specific language governing permissions and limitations under the Apache Lic
391395
dataType: options.dataType,
392396
data: data,
393397
type: type,
394-
cache: false,
398+
cache: cache,
399+
jsonpCallback: jsonpCallback,
395400
success: function (data) {
396401
if (requestNumber < requestSequence) {
397402
return;

0 commit comments

Comments
 (0)