js: use jsonp to get remote jsonp sources (#47869)

This commit is contained in:
Frédéric Péters 2020-10-20 10:25:04 +02:00
parent 29728ef0c0
commit 19d17c7c03
1 changed files with 7 additions and 1 deletions

View File

@ -379,9 +379,15 @@ $(function() {
options.placeholder = '...';
options.allowClear = true;
}
var url = $(elem).data('select2-url');
if (url.indexOf('/api/autocomplete/') == 0) { // local proxying
var data_type = 'json';
} else {
var data_type = 'jsonp';
}
options.ajax = {
delay: 250,
dataType: 'json',
dataType: data_type,
data: function(params) {
return {q: params.term, page_limit: 10};
},