--- a/js/DataTables/Plugins/editor.select2.js +++ b/js/DataTables/Plugins/editor.select2.js @@ -207,6 +207,12 @@ _fieldTypes.select2 = { } if ( needAjax ) { + // beforeSend() is using plain-text value of the 'url' parameter. + // We have to determine the actual value of the 'url' themselves. + var url = (typeof conf.opts.ajax.url === 'function') + ? conf.opts.ajax.url.call() + : conf.opts.ajax.url; + $.ajax( $.extend( { beforeSend: function ( jqXhr, settings ) { // Add an initial data request to the server, but don't @@ -215,9 +221,10 @@ _fieldTypes.select2 = { JSON.stringify(val); if ( settings.type === 'GET' ) { - settings.url += settings.url.indexOf('?') === -1 ? + url += url.indexOf('?') === -1 ? '?'+initData : '&'+initData; + settings.url = url; } else { settings.data = settings.data ?