Added a check for the results
key in AJAX responses
This should prevent users from running into unexpected errors when they do not return an object with the `results` key containing an array. This closes https://github.com/select2/select2/issues/2950.
This commit is contained in:
parent
850816ee77
commit
5b4e1eab42
10
dist/js/select2.amd.full.js
vendored
10
dist/js/select2.amd.full.js
vendored
@ -2626,6 +2626,16 @@ define('select2/data/ajax',[
|
|||||||
$request.success(function (data) {
|
$request.success(function (data) {
|
||||||
var results = self.processResults(data, params);
|
var results = self.processResults(data, params);
|
||||||
|
|
||||||
|
if (console && console.error) {
|
||||||
|
// Check to make sure that the response included a `results` key.
|
||||||
|
if (!results || !results.results || !$.isArray(results.results)) {
|
||||||
|
console.error(
|
||||||
|
'Select2: The AJAX results did not return an array in the ' +
|
||||||
|
'`results` key of the response.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
10
dist/js/select2.amd.js
vendored
10
dist/js/select2.amd.js
vendored
@ -2626,6 +2626,16 @@ define('select2/data/ajax',[
|
|||||||
$request.success(function (data) {
|
$request.success(function (data) {
|
||||||
var results = self.processResults(data, params);
|
var results = self.processResults(data, params);
|
||||||
|
|
||||||
|
if (console && console.error) {
|
||||||
|
// Check to make sure that the response included a `results` key.
|
||||||
|
if (!results || !results.results || !$.isArray(results.results)) {
|
||||||
|
console.error(
|
||||||
|
'Select2: The AJAX results did not return an array in the ' +
|
||||||
|
'`results` key of the response.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
10
dist/js/select2.full.js
vendored
10
dist/js/select2.full.js
vendored
@ -12161,6 +12161,16 @@ define('select2/data/ajax',[
|
|||||||
$request.success(function (data) {
|
$request.success(function (data) {
|
||||||
var results = self.processResults(data, params);
|
var results = self.processResults(data, params);
|
||||||
|
|
||||||
|
if (console && console.error) {
|
||||||
|
// Check to make sure that the response included a `results` key.
|
||||||
|
if (!results || !results.results || !$.isArray(results.results)) {
|
||||||
|
console.error(
|
||||||
|
'Select2: The AJAX results did not return an array in the ' +
|
||||||
|
'`results` key of the response.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
4
dist/js/select2.full.min.js
vendored
4
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
10
dist/js/select2.js
vendored
10
dist/js/select2.js
vendored
@ -3054,6 +3054,16 @@ define('select2/data/ajax',[
|
|||||||
$request.success(function (data) {
|
$request.success(function (data) {
|
||||||
var results = self.processResults(data, params);
|
var results = self.processResults(data, params);
|
||||||
|
|
||||||
|
if (console && console.error) {
|
||||||
|
// Check to make sure that the response included a `results` key.
|
||||||
|
if (!results || !results.results || !$.isArray(results.results)) {
|
||||||
|
console.error(
|
||||||
|
'Select2: The AJAX results did not return an array in the ' +
|
||||||
|
'`results` key of the response.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
4
dist/js/select2.min.js
vendored
4
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
10
src/js/select2/data/ajax.js
vendored
10
src/js/select2/data/ajax.js
vendored
@ -46,6 +46,16 @@ define([
|
|||||||
$request.success(function (data) {
|
$request.success(function (data) {
|
||||||
var results = self.processResults(data, params);
|
var results = self.processResults(data, params);
|
||||||
|
|
||||||
|
if (console && console.error) {
|
||||||
|
// Check to make sure that the response included a `results` key.
|
||||||
|
if (!results || !results.results || !$.isArray(results.results)) {
|
||||||
|
console.error(
|
||||||
|
'Select2: The AJAX results did not return an array in the ' +
|
||||||
|
'`results` key of the response.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user